diff --git a/chatbot_ui/app/run.py b/chatbot_ui/app/run.py index c8fcccd1..b0d5acc6 100644 --- a/chatbot_ui/app/run.py +++ b/chatbot_ui/app/run.py @@ -143,10 +143,13 @@ def chat(query: Optional[str], conversation: Optional[List[Tuple[str, str]]], st history[-1]["model"] = chunk.model if chunk.choices[0].delta.content: + if not history[-1]["content"]: + history[-1]["content"] = "" history[-1]["content"] = ( history[-1]["content"] + chunk.choices[0].delta.content ) - history[-1]["tool_calls"] = chunk.choices[0].delta.tool_calls + if chunk.choices[0].delta.tool_calls: + history[-1]["tool_calls"] = chunk.choices[0].delta.tool_calls if chunk.model and chunk.choices[0].delta.content: messages[-1] = ( diff --git a/crates/prompt_gateway/src/stream_context.rs b/crates/prompt_gateway/src/stream_context.rs index 6ababa70..c4a15f47 100644 --- a/crates/prompt_gateway/src/stream_context.rs +++ b/crates/prompt_gateway/src/stream_context.rs @@ -688,6 +688,7 @@ impl StreamContext { if self.streaming_response {} + self.tool_calls = None; return self.send_http_response( StatusCode::OK.as_u16().into(), vec![("Powered-By", "Katanemo")],