pydantic-ai 0.0.31__tar.gz → 0.0.32__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pydantic-ai might be problematic. Click here for more details.

Files changed (62) hide show
  1. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/PKG-INFO +4 -4
  2. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/pyproject.toml +12 -4
  3. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/models/test_instrumented.py +21 -5
  4. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/test_logfire.py +58 -56
  5. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/.gitignore +0 -0
  6. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/LICENSE +0 -0
  7. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/Makefile +0 -0
  8. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/README.md +0 -0
  9. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/__init__.py +0 -0
  10. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/assets/kiwi.png +0 -0
  11. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/assets/marcelo.mp3 +0 -0
  12. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/conftest.py +0 -0
  13. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/example_modules/README.md +0 -0
  14. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/example_modules/bank_database.py +0 -0
  15. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/example_modules/fake_database.py +0 -0
  16. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/example_modules/weather_service.py +0 -0
  17. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/graph/__init__.py +0 -0
  18. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/graph/test_graph.py +0 -0
  19. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/graph/test_history.py +0 -0
  20. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/graph/test_mermaid.py +0 -0
  21. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/graph/test_state.py +0 -0
  22. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/graph/test_utils.py +0 -0
  23. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/import_examples.py +0 -0
  24. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/json_body_serializer.py +0 -0
  25. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/models/__init__.py +0 -0
  26. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/models/cassettes/test_anthropic/test_image_url_input.yaml +0 -0
  27. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/models/cassettes/test_anthropic/test_image_url_input_invalid_mime_type.yaml +0 -0
  28. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/models/cassettes/test_anthropic/test_multiple_parallel_tool_calls.yaml +0 -0
  29. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/models/cassettes/test_gemini/test_image_as_binary_content_input.yaml +0 -0
  30. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/models/cassettes/test_gemini/test_image_url_input.yaml +0 -0
  31. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/models/cassettes/test_groq/test_image_as_binary_content_input.yaml +0 -0
  32. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/models/cassettes/test_groq/test_image_url_input.yaml +0 -0
  33. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/models/cassettes/test_openai/test_audio_as_binary_content_input.yaml +0 -0
  34. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/models/cassettes/test_openai/test_image_as_binary_content_input.yaml +0 -0
  35. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/models/cassettes/test_openai/test_openai_o1_mini_system_role[developer].yaml +0 -0
  36. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/models/cassettes/test_openai/test_openai_o1_mini_system_role[system].yaml +0 -0
  37. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/models/mock_async_stream.py +0 -0
  38. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/models/test_anthropic.py +0 -0
  39. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/models/test_cohere.py +0 -0
  40. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/models/test_fallback.py +0 -0
  41. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/models/test_gemini.py +0 -0
  42. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/models/test_groq.py +0 -0
  43. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/models/test_mistral.py +0 -0
  44. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/models/test_model.py +0 -0
  45. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/models/test_model_function.py +0 -0
  46. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/models/test_model_names.py +0 -0
  47. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/models/test_model_test.py +0 -0
  48. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/models/test_openai.py +0 -0
  49. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/models/test_vertexai.py +0 -0
  50. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/test_agent.py +0 -0
  51. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/test_deps.py +0 -0
  52. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/test_examples.py +0 -0
  53. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/test_format_as_xml.py +0 -0
  54. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/test_json_body_serializer.py +0 -0
  55. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/test_live.py +0 -0
  56. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/test_parts_manager.py +0 -0
  57. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/test_streaming.py +0 -0
  58. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/test_tools.py +0 -0
  59. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/test_usage_limits.py +0 -0
  60. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/test_utils.py +0 -0
  61. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/typed_agent.py +0 -0
  62. {pydantic_ai-0.0.31 → pydantic_ai-0.0.32}/tests/typed_graph.py +0 -0
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pydantic-ai
3
- Version: 0.0.31
3
+ Version: 0.0.32
4
4
  Summary: Agent Framework / shim to use Pydantic with LLMs
5
5
  Project-URL: Homepage, https://ai.pydantic.dev
6
6
  Project-URL: Source, https://github.com/pydantic/pydantic-ai
7
7
  Project-URL: Documentation, https://ai.pydantic.dev
8
8
  Project-URL: Changelog, https://github.com/pydantic/pydantic-ai/releases
9
- Author-email: Samuel Colvin <samuel@pydantic.dev>
9
+ Author-email: Samuel Colvin <samuel@pydantic.dev>, Marcelo Trylesinski <marcelotryle@gmail.com>, David Montague <david@pydantic.dev>, Alex Hall <alex@pydantic.dev>
10
10
  License-Expression: MIT
11
11
  License-File: LICENSE
12
12
  Classifier: Development Status :: 4 - Beta
@@ -28,9 +28,9 @@ Classifier: Topic :: Internet
28
28
  Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
29
29
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
30
30
  Requires-Python: >=3.9
31
- Requires-Dist: pydantic-ai-slim[anthropic,cohere,groq,mistral,openai,vertexai]==0.0.31
31
+ Requires-Dist: pydantic-ai-slim[anthropic,cohere,groq,mistral,openai,vertexai]==0.0.32
32
32
  Provides-Extra: examples
33
- Requires-Dist: pydantic-ai-examples==0.0.31; extra == 'examples'
33
+ Requires-Dist: pydantic-ai-examples==0.0.32; extra == 'examples'
34
34
  Provides-Extra: logfire
35
35
  Requires-Dist: logfire>=2.3; extra == 'logfire'
36
36
  Description-Content-Type: text/markdown
@@ -4,9 +4,14 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "pydantic-ai"
7
- version = "0.0.31"
7
+ version = "0.0.32"
8
8
  description = "Agent Framework / shim to use Pydantic with LLMs"
9
- authors = [{ name = "Samuel Colvin", email = "samuel@pydantic.dev" }]
9
+ authors = [
10
+ { name = "Samuel Colvin", email = "samuel@pydantic.dev" },
11
+ { name = "Marcelo Trylesinski", email = "marcelotryle@gmail.com" },
12
+ { name = "David Montague", email = "david@pydantic.dev" },
13
+ { name = "Alex Hall", email = "alex@pydantic.dev" },
14
+ ]
10
15
  license = "MIT"
11
16
  readme = "README.md"
12
17
  classifiers = [
@@ -32,7 +37,7 @@ classifiers = [
32
37
  requires-python = ">=3.9"
33
38
 
34
39
  dependencies = [
35
- "pydantic-ai-slim[openai,vertexai,groq,anthropic,mistral,cohere]==0.0.31",
40
+ "pydantic-ai-slim[openai,vertexai,groq,anthropic,mistral,cohere]==0.0.32",
36
41
  ]
37
42
 
38
43
  [project.urls]
@@ -42,7 +47,7 @@ Documentation = "https://ai.pydantic.dev"
42
47
  Changelog = "https://github.com/pydantic/pydantic-ai/releases"
43
48
 
44
49
  [project.optional-dependencies]
45
- examples = ["pydantic-ai-examples==0.0.31"]
50
+ examples = ["pydantic-ai-examples==0.0.32"]
46
51
  logfire = ["logfire>=2.3"]
47
52
 
48
53
  [tool.uv.sources]
@@ -165,6 +170,9 @@ exclude_lines = [
165
170
  [tool.logfire]
166
171
  ignore_no_config = true
167
172
 
173
+ [tool.inline-snapshot]
174
+ format-command="ruff format --stdin-filename {filename}"
175
+
168
176
  [tool.inline-snapshot.shortcuts]
169
177
  snap-fix = ["create", "fix"]
170
178
  snap = ["create"]
@@ -106,7 +106,7 @@ class MyResponseStream(StreamedResponse):
106
106
  @pytest.mark.anyio
107
107
  @requires_logfire_events
108
108
  async def test_instrumented_model(capfire: CaptureLogfire):
109
- model = InstrumentedModel.from_logfire(MyModel(), event_mode='logs')
109
+ model = InstrumentedModel(MyModel(), event_mode='logs')
110
110
  assert model.system == 'my_system'
111
111
  assert model.model_name == 'my_model'
112
112
 
@@ -168,6 +168,7 @@ async def test_instrumented_model(capfire: CaptureLogfire):
168
168
  'severity_text': None,
169
169
  'attributes': {
170
170
  'gen_ai.system': 'my_system',
171
+ 'gen_ai.message.index': 0,
171
172
  'event.name': 'gen_ai.system.message',
172
173
  },
173
174
  'timestamp': 2000000000,
@@ -182,6 +183,7 @@ async def test_instrumented_model(capfire: CaptureLogfire):
182
183
  'severity_text': None,
183
184
  'attributes': {
184
185
  'gen_ai.system': 'my_system',
186
+ 'gen_ai.message.index': 0,
185
187
  'event.name': 'gen_ai.user.message',
186
188
  },
187
189
  'timestamp': 4000000000,
@@ -196,6 +198,7 @@ async def test_instrumented_model(capfire: CaptureLogfire):
196
198
  'severity_text': None,
197
199
  'attributes': {
198
200
  'gen_ai.system': 'my_system',
201
+ 'gen_ai.message.index': 0,
199
202
  'event.name': 'gen_ai.tool.message',
200
203
  },
201
204
  'timestamp': 6000000000,
@@ -218,6 +221,7 @@ Fix the errors and try again.\
218
221
  'severity_text': None,
219
222
  'attributes': {
220
223
  'gen_ai.system': 'my_system',
224
+ 'gen_ai.message.index': 0,
221
225
  'event.name': 'gen_ai.tool.message',
222
226
  },
223
227
  'timestamp': 8000000000,
@@ -239,6 +243,7 @@ Fix the errors and try again.\
239
243
  'severity_text': None,
240
244
  'attributes': {
241
245
  'gen_ai.system': 'my_system',
246
+ 'gen_ai.message.index': 0,
242
247
  'event.name': 'gen_ai.user.message',
243
248
  },
244
249
  'timestamp': 10000000000,
@@ -253,6 +258,7 @@ Fix the errors and try again.\
253
258
  'severity_text': None,
254
259
  'attributes': {
255
260
  'gen_ai.system': 'my_system',
261
+ 'gen_ai.message.index': 1,
256
262
  'event.name': 'gen_ai.assistant.message',
257
263
  },
258
264
  'timestamp': 12000000000,
@@ -324,7 +330,7 @@ async def test_instrumented_model_not_recording():
324
330
  @pytest.mark.anyio
325
331
  @requires_logfire_events
326
332
  async def test_instrumented_model_stream(capfire: CaptureLogfire):
327
- model = InstrumentedModel.from_logfire(MyModel(), event_mode='logs')
333
+ model = InstrumentedModel(MyModel(), event_mode='logs')
328
334
 
329
335
  messages: list[ModelMessage] = [
330
336
  ModelRequest(
@@ -380,6 +386,7 @@ async def test_instrumented_model_stream(capfire: CaptureLogfire):
380
386
  'severity_text': None,
381
387
  'attributes': {
382
388
  'gen_ai.system': 'my_system',
389
+ 'gen_ai.message.index': 0,
383
390
  'event.name': 'gen_ai.user.message',
384
391
  },
385
392
  'timestamp': 2000000000,
@@ -406,7 +413,7 @@ async def test_instrumented_model_stream(capfire: CaptureLogfire):
406
413
  @pytest.mark.anyio
407
414
  @requires_logfire_events
408
415
  async def test_instrumented_model_stream_break(capfire: CaptureLogfire):
409
- model = InstrumentedModel.from_logfire(MyModel(), event_mode='logs')
416
+ model = InstrumentedModel(MyModel(), event_mode='logs')
410
417
 
411
418
  messages: list[ModelMessage] = [
412
419
  ModelRequest(
@@ -474,6 +481,7 @@ async def test_instrumented_model_stream_break(capfire: CaptureLogfire):
474
481
  'severity_text': None,
475
482
  'attributes': {
476
483
  'gen_ai.system': 'my_system',
484
+ 'gen_ai.message.index': 0,
477
485
  'event.name': 'gen_ai.user.message',
478
486
  },
479
487
  'timestamp': 2000000000,
@@ -555,12 +563,14 @@ async def test_instrumented_model_attributes_mode(capfire: CaptureLogfire):
555
563
  'event.name': 'gen_ai.system.message',
556
564
  'content': 'system_prompt',
557
565
  'role': 'system',
566
+ 'gen_ai.message.index': 0,
558
567
  'gen_ai.system': 'my_system',
559
568
  },
560
569
  {
561
570
  'event.name': 'gen_ai.user.message',
562
571
  'content': 'user_prompt',
563
572
  'role': 'user',
573
+ 'gen_ai.message.index': 0,
564
574
  'gen_ai.system': 'my_system',
565
575
  },
566
576
  {
@@ -568,6 +578,7 @@ async def test_instrumented_model_attributes_mode(capfire: CaptureLogfire):
568
578
  'content': 'tool_return_content',
569
579
  'role': 'tool',
570
580
  'id': 'tool_call_3',
581
+ 'gen_ai.message.index': 0,
571
582
  'gen_ai.system': 'my_system',
572
583
  },
573
584
  {
@@ -579,6 +590,7 @@ Fix the errors and try again.\
579
590
  """,
580
591
  'role': 'tool',
581
592
  'id': 'tool_call_4',
593
+ 'gen_ai.message.index': 0,
582
594
  'gen_ai.system': 'my_system',
583
595
  },
584
596
  {
@@ -589,12 +601,14 @@ retry_prompt2
589
601
  Fix the errors and try again.\
590
602
  """,
591
603
  'role': 'user',
604
+ 'gen_ai.message.index': 0,
592
605
  'gen_ai.system': 'my_system',
593
606
  },
594
607
  {
595
608
  'event.name': 'gen_ai.assistant.message',
596
609
  'role': 'assistant',
597
610
  'content': 'text3',
611
+ 'gen_ai.message.index': 1,
598
612
  'gen_ai.system': 'my_system',
599
613
  },
600
614
  {
@@ -641,7 +655,7 @@ def test_messages_to_otel_events_serialization_errors():
641
655
 
642
656
  class Bar:
643
657
  def __repr__(self):
644
- raise ValueError
658
+ raise ValueError('error!')
645
659
 
646
660
  messages = [
647
661
  ModelResponse(parts=[ToolCallPart('tool', {'arg': Foo()})]),
@@ -654,10 +668,12 @@ def test_messages_to_otel_events_serialization_errors():
654
668
  [
655
669
  {
656
670
  'body': "{'role': 'assistant', 'tool_calls': [{'id': None, 'type': 'function', 'function': {'name': 'tool', 'arguments': {'arg': Foo()}}}]}",
671
+ 'gen_ai.message.index': 0,
657
672
  'event.name': 'gen_ai.assistant.message',
658
673
  },
659
674
  {
660
- 'body': 'Unable to serialize event body',
675
+ 'body': 'Unable to serialize: error!',
676
+ 'gen_ai.message.index': 1,
661
677
  'event.name': 'gen_ai.tool.message',
662
678
  },
663
679
  ]
@@ -4,7 +4,7 @@ from dataclasses import dataclass
4
4
  from typing import Any, Callable
5
5
 
6
6
  import pytest
7
- from dirty_equals import IsInt, IsJson
7
+ from dirty_equals import IsJson
8
8
  from inline_snapshot import snapshot
9
9
  from typing_extensions import NotRequired, TypedDict
10
10
 
@@ -59,7 +59,7 @@ def get_logfire_summary(capfire: CaptureLogfire) -> Callable[[], LogfireSummary]
59
59
 
60
60
  @pytest.mark.skipif(not logfire_installed, reason='logfire not installed')
61
61
  def test_logfire(get_logfire_summary: Callable[[], LogfireSummary]) -> None:
62
- my_agent = Agent(model=TestModel())
62
+ my_agent = Agent(model=TestModel(), instrument=True)
63
63
 
64
64
  @my_agent.tool_plain
65
65
  async def my_ret(x: int) -> str:
@@ -73,53 +73,32 @@ def test_logfire(get_logfire_summary: Callable[[], LogfireSummary]) -> None:
73
73
  [
74
74
  {
75
75
  'id': 0,
76
- 'message': 'my_agent run prompt=Hello',
76
+ 'message': 'my_agent run',
77
77
  'children': [
78
- {'id': 1, 'message': 'preparing model request params run_step=1'},
78
+ {'id': 1, 'message': 'preparing model request params'},
79
79
  {'id': 2, 'message': 'chat test'},
80
- {
81
- 'id': 3,
82
- 'message': 'handle model response -> tool-return',
83
- 'children': [{'id': 4, 'message': "running tools=['my_ret']"}],
84
- },
85
- {'id': 5, 'message': 'preparing model request params run_step=2'},
86
- {'id': 6, 'message': 'chat test'},
87
- {'id': 7, 'message': 'handle model response -> final result'},
80
+ {'id': 3, 'message': 'running tools: my_ret'},
81
+ {'id': 4, 'message': 'preparing model request params'},
82
+ {'id': 5, 'message': 'chat test'},
88
83
  ],
89
84
  }
90
85
  ]
91
86
  )
92
87
  assert summary.attributes[0] == snapshot(
93
88
  {
94
- 'code.filepath': 'test_logfire.py',
95
- 'code.function': 'test_logfire',
96
- 'code.lineno': 123,
97
- 'prompt': 'Hello',
98
- 'agent': IsJson(
99
- {
100
- 'model': {
101
- 'call_tools': 'all',
102
- 'custom_result_text': None,
103
- 'custom_result_args': None,
104
- 'seed': 0,
105
- 'last_model_request_parameters': None,
106
- },
107
- 'name': 'my_agent',
108
- 'end_strategy': 'early',
109
- 'model_settings': None,
110
- }
111
- ),
112
89
  'model_name': 'test',
113
90
  'agent_name': 'my_agent',
114
- 'logfire.msg_template': '{agent_name} run {prompt=}',
115
- 'logfire.msg': 'my_agent run prompt=Hello',
91
+ 'logfire.msg': 'my_agent run',
116
92
  'logfire.span_type': 'span',
93
+ 'gen_ai.usage.input_tokens': 103,
94
+ 'gen_ai.usage.output_tokens': 12,
117
95
  'all_messages_events': IsJson(
118
96
  snapshot(
119
97
  [
120
98
  {
121
99
  'content': 'Hello',
122
100
  'role': 'user',
101
+ 'gen_ai.message.index': 0,
123
102
  'event.name': 'gen_ai.user.message',
124
103
  },
125
104
  {
@@ -134,44 +113,31 @@ def test_logfire(get_logfire_summary: Callable[[], LogfireSummary]) -> None:
134
113
  },
135
114
  }
136
115
  ],
116
+ 'gen_ai.message.index': 1,
137
117
  'event.name': 'gen_ai.assistant.message',
138
118
  },
139
119
  {
140
120
  'content': '1',
141
121
  'role': 'tool',
142
122
  'id': None,
123
+ 'gen_ai.message.index': 2,
143
124
  'event.name': 'gen_ai.tool.message',
144
125
  },
145
126
  {
146
127
  'role': 'assistant',
147
128
  'content': '{"my_ret":"1"}',
129
+ 'gen_ai.message.index': 3,
148
130
  'event.name': 'gen_ai.assistant.message',
149
131
  },
150
132
  ]
151
133
  )
152
134
  ),
153
- 'usage': IsJson(
154
- {'requests': 2, 'request_tokens': 103, 'response_tokens': 12, 'total_tokens': 115, 'details': None}
155
- ),
135
+ 'final_result': '{"my_ret":"1"}',
156
136
  'logfire.json_schema': IsJson(
157
137
  snapshot(
158
138
  {
159
139
  'type': 'object',
160
- 'properties': {
161
- 'prompt': {},
162
- 'agent': {
163
- 'type': 'object',
164
- 'title': 'Agent',
165
- 'x-python-datatype': 'dataclass',
166
- 'properties': {
167
- 'model': {'type': 'object', 'title': 'TestModel', 'x-python-datatype': 'dataclass'}
168
- },
169
- },
170
- 'model_name': {},
171
- 'agent_name': {},
172
- 'usage': {'type': 'object', 'title': 'Usage', 'x-python-datatype': 'dataclass'},
173
- 'all_messages_events': {'type': 'array'},
174
- },
140
+ 'properties': {'all_messages_events': {'type': 'array'}, 'final_result': {'type': 'object'}},
175
141
  }
176
142
  )
177
143
  ),
@@ -179,13 +145,49 @@ def test_logfire(get_logfire_summary: Callable[[], LogfireSummary]) -> None:
179
145
  )
180
146
  assert summary.attributes[1] == snapshot(
181
147
  {
182
- 'code.filepath': 'test_logfire.py',
183
- 'code.function': 'test_logfire',
184
- 'code.lineno': IsInt(),
185
148
  'run_step': 1,
186
- 'logfire.msg_template': 'preparing model request params {run_step=}',
187
149
  'logfire.span_type': 'span',
188
- 'logfire.msg': 'preparing model request params run_step=1',
189
- 'logfire.json_schema': '{"type":"object","properties":{"run_step":{}}}',
150
+ 'logfire.msg': 'preparing model request params',
151
+ }
152
+ )
153
+ assert summary.attributes[2] == snapshot(
154
+ {
155
+ 'gen_ai.operation.name': 'chat',
156
+ 'gen_ai.system': 'test',
157
+ 'gen_ai.request.model': 'test',
158
+ 'logfire.span_type': 'span',
159
+ 'logfire.msg': 'chat test',
160
+ 'gen_ai.response.model': 'test',
161
+ 'gen_ai.usage.input_tokens': 51,
162
+ 'gen_ai.usage.output_tokens': 4,
163
+ 'events': IsJson(
164
+ snapshot(
165
+ [
166
+ {
167
+ 'event.name': 'gen_ai.user.message',
168
+ 'content': 'Hello',
169
+ 'role': 'user',
170
+ 'gen_ai.message.index': 0,
171
+ 'gen_ai.system': 'test',
172
+ },
173
+ {
174
+ 'event.name': 'gen_ai.choice',
175
+ 'index': 0,
176
+ 'message': {
177
+ 'role': 'assistant',
178
+ 'tool_calls': [
179
+ {
180
+ 'id': None,
181
+ 'type': 'function',
182
+ 'function': {'name': 'my_ret', 'arguments': {'x': 0}},
183
+ }
184
+ ],
185
+ },
186
+ 'gen_ai.system': 'test',
187
+ },
188
+ ]
189
+ )
190
+ ),
191
+ 'logfire.json_schema': '{"type": "object", "properties": {"events": {"type": "array"}}}',
190
192
  }
191
193
  )
File without changes
File without changes
File without changes
File without changes