Skip to content

Commit 0035276

Browse files
authored
Upgrade deps, fix anthropic tests (#1062)
1 parent 74c24d0 commit 0035276

File tree

3 files changed

+174
-159
lines changed

3 files changed

+174
-159
lines changed

tests/otel_integrations/test_anthropic.py

Lines changed: 55 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -150,50 +150,57 @@ def test_sync_messages(instrumented_client: anthropic.Anthropic, exporter: TestE
150150
'code.function': 'test_sync_messages',
151151
'code.lineno': 123,
152152
'request_data': IsJson(
153-
{
154-
'max_tokens': 1000,
155-
'system': 'You are a helpful assistant.',
156-
'messages': [{'role': 'user', 'content': 'What is four plus five?'}],
157-
'model': 'claude-3-haiku-20240307',
158-
}
153+
snapshot(
154+
{
155+
'max_tokens': 1000,
156+
'system': 'You are a helpful assistant.',
157+
'messages': [{'role': 'user', 'content': 'What is four plus five?'}],
158+
'model': 'claude-3-haiku-20240307',
159+
}
160+
)
159161
),
160162
'async': False,
161163
'logfire.msg_template': 'Message with {request_data[model]!r}',
162164
'logfire.msg': "Message with 'claude-3-haiku-20240307'",
163165
'logfire.span_type': 'span',
164166
'logfire.tags': ('LLM',),
165167
'response_data': IsJson(
166-
{
167-
'message': {
168-
'content': 'Nine',
169-
'role': 'assistant',
170-
},
171-
'usage': {
172-
'input_tokens': 2,
173-
'output_tokens': 3,
174-
'cache_creation_input_tokens': None,
175-
'cache_read_input_tokens': None,
176-
},
177-
}
168+
snapshot(
169+
{
170+
'message': {
171+
'content': 'Nine',
172+
'role': 'assistant',
173+
},
174+
'usage': {
175+
'input_tokens': 2,
176+
'output_tokens': 3,
177+
'cache_creation_input_tokens': None,
178+
'cache_read_input_tokens': None,
179+
'server_tool_use': None,
180+
},
181+
}
182+
)
178183
),
179184
'logfire.json_schema': IsJson(
180-
{
181-
'type': 'object',
182-
'properties': {
183-
'request_data': {'type': 'object'},
184-
'async': {},
185-
'response_data': {
186-
'type': 'object',
187-
'properties': {
188-
'usage': {
189-
'type': 'object',
190-
'title': 'Usage',
191-
'x-python-datatype': 'PydanticModel',
185+
snapshot(
186+
{
187+
'type': 'object',
188+
'properties': {
189+
'request_data': {'type': 'object'},
190+
'async': {},
191+
'response_data': {
192+
'type': 'object',
193+
'properties': {
194+
'usage': {
195+
'type': 'object',
196+
'title': 'Usage',
197+
'x-python-datatype': 'PydanticModel',
198+
},
192199
},
193200
},
194201
},
195-
},
196-
}
202+
}
203+
)
197204
),
198205
},
199206
}
@@ -236,18 +243,21 @@ async def test_async_messages(instrumented_async_client: anthropic.AsyncAnthropi
236243
'logfire.span_type': 'span',
237244
'logfire.tags': ('LLM',),
238245
'response_data': IsJson(
239-
{
240-
'message': {
241-
'content': 'Nine',
242-
'role': 'assistant',
243-
},
244-
'usage': {
245-
'input_tokens': 2,
246-
'output_tokens': 3,
247-
'cache_creation_input_tokens': None,
248-
'cache_read_input_tokens': None,
249-
},
250-
}
246+
snapshot(
247+
{
248+
'message': {
249+
'content': 'Nine',
250+
'role': 'assistant',
251+
},
252+
'usage': {
253+
'input_tokens': 2,
254+
'output_tokens': 3,
255+
'cache_creation_input_tokens': None,
256+
'cache_read_input_tokens': None,
257+
'server_tool_use': None,
258+
},
259+
}
260+
)
251261
),
252262
'logfire.json_schema': IsJson(
253263
{
@@ -485,7 +495,7 @@ def test_tool_messages(instrumented_client: anthropic.Anthropic, exporter: TestE
485495
'logfire.msg': "Message with 'claude-3-haiku-20240307'",
486496
'logfire.span_type': 'span',
487497
'logfire.tags': ('LLM',),
488-
'response_data': '{"message":{"role":"assistant","tool_calls":[{"function":{"arguments":"{\\"input\\":{\\"param\\":\\"param\\"}}","name":"tool"}}]},"usage":{"cache_creation_input_tokens":null,"cache_read_input_tokens":null,"input_tokens":2,"output_tokens":3}}',
498+
'response_data': '{"message":{"role":"assistant","tool_calls":[{"function":{"arguments":"{\\"input\\":{\\"param\\":\\"param\\"}}","name":"tool"}}]},"usage":{"cache_creation_input_tokens":null,"cache_read_input_tokens":null,"input_tokens":2,"output_tokens":3,"server_tool_use":null}}',
489499
'logfire.json_schema': '{"type":"object","properties":{"request_data":{"type":"object"},"async":{},"response_data":{"type":"object","properties":{"usage":{"type":"object","title":"Usage","x-python-datatype":"PydanticModel"}}}}}',
490500
},
491501
}

tests/otel_integrations/test_anthropic_bedrock.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -95,18 +95,21 @@ def test_sync_messages(mock_client: AnthropicBedrock, exporter: TestExporter):
9595
'logfire.span_type': 'span',
9696
'logfire.tags': ('LLM',),
9797
'response_data': IsJson(
98-
{
99-
'message': {
100-
'content': 'Nine',
101-
'role': 'assistant',
102-
},
103-
'usage': {
104-
'input_tokens': 2,
105-
'output_tokens': 3,
106-
'cache_creation_input_tokens': None,
107-
'cache_read_input_tokens': None,
108-
},
109-
}
98+
snapshot(
99+
{
100+
'message': {
101+
'content': 'Nine',
102+
'role': 'assistant',
103+
},
104+
'usage': {
105+
'input_tokens': 2,
106+
'output_tokens': 3,
107+
'cache_creation_input_tokens': None,
108+
'cache_read_input_tokens': None,
109+
'server_tool_use': None,
110+
},
111+
}
112+
)
110113
),
111114
'logfire.json_schema': IsJson(
112115
{

0 commit comments

Comments
 (0)