From 0f8ffbfbbd2ebc44e3ca7c1d3ab71fdcad37190e Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Fri, 26 Jan 2024 13:35:03 -0800 Subject: [PATCH] Fix compatibility with llm-anyscale-endpoints, refs #401 --- llm/default_plugins/openai_models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/llm/default_plugins/openai_models.py b/llm/default_plugins/openai_models.py index b1c66e2..81b3268 100644 --- a/llm/default_plugins/openai_models.py +++ b/llm/default_plugins/openai_models.py @@ -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, } )