From 21793d080a9aabcd470366fd68e9e6b1a336b885 Mon Sep 17 00:00:00 2001 From: Fangyin Cheng Date: Wed, 12 Mar 2025 00:11:41 +0800 Subject: [PATCH] fix(chat): Fix chat completions API error --- packages/dbgpt-app/src/dbgpt_app/scene/base_chat.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/dbgpt-app/src/dbgpt_app/scene/base_chat.py b/packages/dbgpt-app/src/dbgpt_app/scene/base_chat.py index f1431702da..3bcc3d92b4 100644 --- a/packages/dbgpt-app/src/dbgpt_app/scene/base_chat.py +++ b/packages/dbgpt-app/src/dbgpt_app/scene/base_chat.py @@ -374,14 +374,15 @@ async def stream_call( ai_response_text, view_message = await self._handle_final_output( final_output, incremental=incremental ) + full_text = view_message + # Return the incremental text + delta_text = full_text[len(previous_text) :] + result_text = delta_text if incremental else full_text if text_output: - full_text = view_message - # Return the incremental text - delta_text = full_text[len(previous_text) :] - yield delta_text if incremental else full_text + yield result_text else: yield ModelOutput.build( - view_message, + result_text, "", error_code=final_output.error_code, usage=final_output.usage,