From 4f3053a8cc72a3c4cda20e90534f2ba2788e0016 Mon Sep 17 00:00:00 2001 From: takatost Date: Tue, 22 Aug 2023 15:58:04 +0800 Subject: [PATCH] fix: xinference chat completion error (#952) --- api/core/third_party/langchain/llms/xinference_llm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/core/third_party/langchain/llms/xinference_llm.py b/api/core/third_party/langchain/llms/xinference_llm.py index c69bfe2e4e..0aa73057aa 100644 --- a/api/core/third_party/langchain/llms/xinference_llm.py +++ b/api/core/third_party/langchain/llms/xinference_llm.py @@ -46,7 +46,7 @@ class XinferenceLLM(Xinference): return combined_text_output else: completion = model.chat(prompt=prompt, generate_config=generate_config) - return completion["choices"][0]["text"] + return completion["choices"][0]["message"]["content"] elif isinstance(model, RESTfulGenerateModelHandle): generate_config: "LlamaCppGenerateConfig" = kwargs.get("generate_config", {}) @@ -82,7 +82,7 @@ class XinferenceLLM(Xinference): completion = combined_text_output else: completion = model.chat(prompt=prompt, generate_config=generate_config) - completion = completion["choices"][0]["text"] + completion = completion["choices"][0]["message"]["content"] if stop is not None: completion = enforce_stop_tokens(completion, stop)