From 34a8fc0cd1a15ab2c4ceba5d19fc65b368175f82 Mon Sep 17 00:00:00 2001 From: "open-swe[bot]" Date: Wed, 6 Aug 2025 16:45:31 +0000 Subject: [PATCH] Apply patch [skip ci] --- .../unit_tests/test_chat_models_gpt_oss.py | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/libs/partners/ollama/tests/unit_tests/test_chat_models_gpt_oss.py b/libs/partners/ollama/tests/unit_tests/test_chat_models_gpt_oss.py index 165bc5ec9dd..60de0091979 100644 --- a/libs/partners/ollama/tests/unit_tests/test_chat_models_gpt_oss.py +++ b/libs/partners/ollama/tests/unit_tests/test_chat_models_gpt_oss.py @@ -288,11 +288,15 @@ class TestGptOssResponseParsing: class TestGptOssIntegration: """Integration tests for gpt-oss model with ChatOllama.""" - @patch("langchain_ollama.chat_models.ChatOllama._create_chat") - def test_invoke_with_tools(self, mock_create_chat: MagicMock) -> None: + @patch("ollama.Client") + def test_invoke_with_tools(self, mock_client_class: MagicMock) -> None: """Test invoking gpt-oss model with tools.""" + # Create mock client instance + mock_client = MagicMock() + mock_client_class.return_value = mock_client + # Mock response with tool call - mock_create_chat.return_value = { + mock_client.chat.return_value = { "message": { "role": "assistant", "content": "", @@ -325,11 +329,15 @@ class TestGptOssIntegration: assert result.tool_calls[0]["name"] == "get_weather" assert result.tool_calls[0]["args"] == {"location": "Berlin", "unit": "celsius"} - @patch("langchain_ollama.chat_models.ChatOllama._create_chat_stream") - def test_stream_with_tools(self, mock_create_stream: MagicMock) -> None: + @patch("ollama.Client") + def test_stream_with_tools(self, mock_client_class: MagicMock) -> None: """Test streaming gpt-oss model with tools.""" + # Create mock client instance + mock_client = MagicMock() + mock_client_class.return_value = mock_client + # Mock streaming response - mock_create_stream.return_value = iter([ + mock_client.chat.return_value = iter([ { "message": {"content": "Let me check the weather for you."}, "done": False, @@ -401,3 +409,4 @@ class TestChatParamsWithGptOss: if "type" in prop: assert isinstance(prop["type"], str) +