Skip to content

Commit

Permalink
Make finish_reason optional in TogetherClient responses (#1743)
Browse files Browse the repository at this point in the history
  • Loading branch information
yifanmai authored Aug 11, 2023
1 parent cc50bd1 commit f5eea4b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/helm/proxy/clients/together_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f5eea4b

Please sign in to comment.