@@ -42,7 +42,7 @@ def test_anthropic_llm_missing_dependency(mock_import: Mock) -> None:
42
42
43
43
def test_anthropic_invoke_happy_path (mock_anthropic : Mock ) -> None :
44
44
mock_anthropic .Anthropic .return_value .messages .create .return_value = MagicMock (
45
- content = "generated text"
45
+ content = [ MagicMock ( text = "generated text" )]
46
46
)
47
47
model_params = {"temperature" : 0.3 }
48
48
llm = AnthropicLLM ("claude-3-opus-20240229" , model_params = model_params )
@@ -59,7 +59,7 @@ def test_anthropic_invoke_happy_path(mock_anthropic: Mock) -> None:
59
59
60
60
def test_anthropic_invoke_with_message_history_happy_path (mock_anthropic : Mock ) -> None :
61
61
mock_anthropic .Anthropic .return_value .messages .create .return_value = MagicMock (
62
- content = "generated text"
62
+ content = [ MagicMock ( text = "generated text" )]
63
63
)
64
64
model_params = {"temperature" : 0.3 }
65
65
llm = AnthropicLLM (
@@ -87,7 +87,7 @@ def test_anthropic_invoke_with_system_instruction(
87
87
mock_anthropic : Mock ,
88
88
) -> None :
89
89
mock_anthropic .Anthropic .return_value .messages .create .return_value = MagicMock (
90
- content = "generated text"
90
+ content = [ MagicMock ( text = "generated text" )]
91
91
)
92
92
model_params = {"temperature" : 0.3 }
93
93
system_instruction = "You are a helpful assistant."
@@ -115,7 +115,7 @@ def test_anthropic_invoke_with_message_history_and_system_instruction(
115
115
mock_anthropic : Mock ,
116
116
) -> None :
117
117
mock_anthropic .Anthropic .return_value .messages .create .return_value = MagicMock (
118
- content = "generated text"
118
+ content = [ MagicMock ( text = "generated text" )]
119
119
)
120
120
model_params = {"temperature" : 0.3 }
121
121
system_instruction = "You are a helpful assistant."
@@ -147,7 +147,7 @@ def test_anthropic_invoke_with_message_history_validation_error(
147
147
mock_anthropic : Mock ,
148
148
) -> None :
149
149
mock_anthropic .Anthropic .return_value .messages .create .return_value = MagicMock (
150
- content = "generated text"
150
+ content = [ MagicMock ( text = "generated text" )]
151
151
)
152
152
model_params = {"temperature" : 0.3 }
153
153
system_instruction = "You are a helpful assistant."
@@ -170,7 +170,7 @@ def test_anthropic_invoke_with_message_history_validation_error(
170
170
@pytest .mark .asyncio
171
171
async def test_anthropic_ainvoke_happy_path (mock_anthropic : Mock ) -> None :
172
172
mock_response = AsyncMock ()
173
- mock_response .content = "Return text"
173
+ mock_response .content = [ MagicMock ( text = "Return text" )]
174
174
mock_model = mock_anthropic .AsyncAnthropic .return_value
175
175
mock_model .messages .create = AsyncMock (return_value = mock_response )
176
176
model_params = {"temperature" : 0.3 }
0 commit comments