Fix compatibility with llm-anyscale-endpoints, refs #401

This commit is contained in:
Simon Willison 2024-01-26 13:35:03 -08:00
parent 9119b03a07
commit 0f8ffbfbbd

View file

@ -427,10 +427,10 @@ def combine_chunks(chunks: List) -> dict:
for item in chunks:
for choice in item.choices:
if choice.logprobs:
if choice.logprobs and hasattr(choice.logprobs, "top_logprobs"):
logprobs.append(
{
"text": choice.text,
"text": choice.text if hasattr(choice, "text") else None,
"top_logprobs": choice.logprobs.top_logprobs,
}
)