From f5eea4b2d1c296fdd7cd2d21b99b80d2c3b11362 Mon Sep 17 00:00:00 2001 From: Yifan Mai Date: Fri, 11 Aug 2023 16:39:59 -0700 Subject: [PATCH] Make `finish_reason` optional in TogetherClient responses (#1743) --- src/helm/proxy/clients/together_client.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/helm/proxy/clients/together_client.py b/src/helm/proxy/clients/together_client.py index 8355428f22..ea57d83981 100644 --- a/src/helm/proxy/clients/together_client.py +++ b/src/helm/proxy/clients/together_client.py @@ -261,11 +261,14 @@ def do_it_sync() -> Dict[Any, Any]: text = cleanup_str(raw_completion["text"], "together") tokens.append(Token(text=text, logprob=0, top_logprobs={})) + raw_finish_reason: Optional[str] = raw_completion.get("finish_reason") + finish_reason: Optional[Dict] = {"reason": raw_finish_reason} if raw_finish_reason else None + completion = Sequence( text=cleanup_str(raw_completion["text"], "together"), logprob=sequence_logprob, tokens=tokens, - finish_reason={"reason": raw_completion["finish_reason"]}, + finish_reason=finish_reason, ) completion = truncate_sequence(completion, request) completions.append(completion)