Build and run agents you can see, understand and trust.
Python agentchatbotlarge-language-modelsllmllm-agentmcpmulti-agentmulti-modalreact-agentrealtime-agentvoice-agentvoice-assistant
fix(ollama): fix the bug in streaming output of ollama chat model (#1082)
qbc238dc3a83c65
diff --git a/src/agentscope/model/_ollama_model.py b/src/agentscope/model/_ollama_model.pyindex fe5307309..82d6cc035 100644--- a/src/agentscope/model/_ollama_model.py+++ b/src/agentscope/model/_ollama_model.py@@ -261,7 +261,7 @@ class OllamaChatModel(ChatModelBase):print(f"Error parsing tool call input: {e}")# Generate response when there's new content or at final chunk- if chunk.done and contents:+ if chunk.done or contents:res = ChatResponse(content=contents,usage=usage,diff --git a/tests/model_anthropic_test.py b/tests/model_anthropic_test.pyindex 49e0d3ddc..7358604cb 100644--- a/tests/model_anthropic_test.py+++ b/tests/model_anthropic_test.py@@ -318,7 +318,7 @@ class TestAnthropicChatModel(IsolatedAsyncioTestCase):async for response in result:responses.append(response)- self.assertGreater(len(responses), 0)+ self.assertEqual(len(responses), 2)final_response = responses[-1]self.assertIsInstance(final_response, ChatResponse)expected_content = [diff --git a/tests/model_ollama_test.py b/tests/model_ollama_test.pyindex eefe1afe2..722b666fa 100644--- a/tests/model_ollama_test.py+++ b/tests/model_ollama_test.py@@ -281,7 +281,7 @@ class TestOllamaChatModel(IsolatedAsyncioTestCase):async for response in result:responses.append(response)- self.assertGreaterEqual(len(responses), 1)+ self.assertEqual(len(responses), 2)final_response = responses[-1]expected_content = [TextBlock(type="text", text="Hello there!")]self.assertEqual(final_response.content, expected_content)diff --git a/tests/model_openai_test.py b/tests/model_openai_test.pyindex 7ce1d6aa6..31f950538 100644--- a/tests/model_openai_test.py+++ b/tests/model_openai_test.py@@ -244,7 +244,7 @@ class TestOpenAIChatModel(IsolatedAsyncioTestCase):async for response in result:responses.append(response)- self.assertGreaterEqual(len(responses), 1)+ self.assertEqual(len(responses), 2)final_response = responses[-1]expected_content = [TextBlock(type="text", text="Hello there!")]self.assertEqual(final_response.content, expected_content)