pydantic-ai-slim 0.2.12__py3-none-any.whl → 0.2.13__py3-none-any.whl

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-slim might be problematic. Click here for more details.

pydantic_ai/_output.py CHANGED
@@ -407,7 +407,7 @@ class OutputTool(Generic[OutputDataT]):
407
407
  if wrap_validation_errors:
408
408
  m = _messages.RetryPromptPart(
409
409
  tool_name=tool_call.tool_name,
410
- content=e.errors(include_url=False),
410
+ content=e.errors(include_url=False, include_context=False),
411
411
  tool_call_id=tool_call.tool_call_id,
412
412
  )
413
413
  raise ToolRetryError(m) from e
@@ -431,7 +431,8 @@ class GeminiStreamedResponse(StreamedResponse):
431
431
  if maybe_event is not None: # pragma: no branch
432
432
  yield maybe_event
433
433
  else:
434
- assert 'function_response' in gemini_part, f'Unexpected part: {gemini_part}' # pragma: no cover
434
+ if not any([key in gemini_part for key in ['function_response', 'thought']]):
435
+ raise AssertionError(f'Unexpected part: {gemini_part}') # pragma: no cover
435
436
 
436
437
  async def _get_gemini_responses(self) -> AsyncIterator[_GeminiResponse]:
437
438
  # This method exists to ensure we only yield completed items, so we don't need to worry about
@@ -605,6 +606,11 @@ class _GeminiFileDataPart(TypedDict):
605
606
  file_data: Annotated[_GeminiFileData, pydantic.Field(alias='fileData')]
606
607
 
607
608
 
609
+ class _GeminiThoughtPart(TypedDict):
610
+ thought: bool
611
+ thought_signature: Annotated[str, pydantic.Field(alias='thoughtSignature')]
612
+
613
+
608
614
  class _GeminiFunctionCallPart(TypedDict):
609
615
  function_call: Annotated[_GeminiFunctionCall, pydantic.Field(alias='functionCall')]
610
616
 
@@ -665,6 +671,8 @@ def _part_discriminator(v: Any) -> str:
665
671
  return 'inline_data' # pragma: no cover
666
672
  elif 'fileData' in v:
667
673
  return 'file_data' # pragma: no cover
674
+ elif 'thought' in v:
675
+ return 'thought'
668
676
  elif 'functionCall' in v or 'function_call' in v:
669
677
  return 'function_call'
670
678
  elif 'functionResponse' in v or 'function_response' in v:
@@ -682,6 +690,7 @@ _GeminiPartUnion = Annotated[
682
690
  Annotated[_GeminiFunctionResponsePart, pydantic.Tag('function_response')],
683
691
  Annotated[_GeminiInlineDataPart, pydantic.Tag('inline_data')],
684
692
  Annotated[_GeminiFileDataPart, pydantic.Tag('file_data')],
693
+ Annotated[_GeminiThoughtPart, pydantic.Tag('thought')],
685
694
  ],
686
695
  pydantic.Discriminator(_part_discriminator),
687
696
  ]
@@ -399,7 +399,7 @@ class GeminiStreamedResponse(StreamedResponse):
399
399
  raise UnexpectedModelBehavior('Streamed response has no content field') # pragma: no cover
400
400
  assert candidate.content.parts is not None
401
401
  for part in candidate.content.parts:
402
- if part.text:
402
+ if part.text is not None:
403
403
  yield self._parts_manager.handle_text_delta(vendor_part_id='content', content=part.text)
404
404
  elif part.function_call:
405
405
  maybe_event = self._parts_manager.handle_tool_call_delta(
@@ -447,7 +447,7 @@ def _process_response_from_parts(
447
447
  ) -> ModelResponse:
448
448
  items: list[ModelResponsePart] = []
449
449
  for part in parts:
450
- if part.text:
450
+ if part.text is not None:
451
451
  items.append(TextPart(content=part.text))
452
452
  elif part.function_call:
453
453
  assert part.function_call.name is not None
@@ -334,7 +334,9 @@ class OpenAIModel(Model):
334
334
  items.append(TextPart(choice.message.content))
335
335
  if choice.message.tool_calls is not None:
336
336
  for c in choice.message.tool_calls:
337
- items.append(ToolCallPart(c.function.name, c.function.arguments, tool_call_id=c.id))
337
+ part = ToolCallPart(c.function.name, c.function.arguments, tool_call_id=c.id)
338
+ part.tool_call_id = _guard_tool_call_id(part)
339
+ items.append(part)
338
340
  return ModelResponse(
339
341
  items,
340
342
  usage=_map_usage(response),
pydantic_ai/tools.py CHANGED
@@ -392,7 +392,7 @@ class Tool(Generic[AgentDepsT]):
392
392
  raise UnexpectedModelBehavior(f'Tool exceeded max retries count of {self.max_retries}') from exc
393
393
  else:
394
394
  if isinstance(exc, ValidationError):
395
- content = exc.errors(include_url=False)
395
+ content = exc.errors(include_url=False, include_context=False)
396
396
  else:
397
397
  content = exc.message
398
398
  return _messages.RetryPromptPart(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pydantic-ai-slim
3
- Version: 0.2.12
3
+ Version: 0.2.13
4
4
  Summary: Agent Framework / shim to use Pydantic with LLMs, slim package
5
5
  Author-email: Samuel Colvin <samuel@pydantic.dev>, Marcelo Trylesinski <marcelotryle@gmail.com>, David Montague <david@pydantic.dev>, Alex Hall <alex@pydantic.dev>
6
6
  License-Expression: MIT
@@ -30,11 +30,11 @@ Requires-Dist: exceptiongroup; python_version < '3.11'
30
30
  Requires-Dist: griffe>=1.3.2
31
31
  Requires-Dist: httpx>=0.27
32
32
  Requires-Dist: opentelemetry-api>=1.28.0
33
- Requires-Dist: pydantic-graph==0.2.12
33
+ Requires-Dist: pydantic-graph==0.2.13
34
34
  Requires-Dist: pydantic>=2.10
35
35
  Requires-Dist: typing-inspection>=0.4.0
36
36
  Provides-Extra: a2a
37
- Requires-Dist: fasta2a==0.2.12; extra == 'a2a'
37
+ Requires-Dist: fasta2a==0.2.13; extra == 'a2a'
38
38
  Provides-Extra: anthropic
39
39
  Requires-Dist: anthropic>=0.52.0; extra == 'anthropic'
40
40
  Provides-Extra: bedrock
@@ -48,7 +48,7 @@ Requires-Dist: cohere>=5.13.11; (platform_system != 'Emscripten') and extra == '
48
48
  Provides-Extra: duckduckgo
49
49
  Requires-Dist: duckduckgo-search>=7.0.0; extra == 'duckduckgo'
50
50
  Provides-Extra: evals
51
- Requires-Dist: pydantic-evals==0.2.12; extra == 'evals'
51
+ Requires-Dist: pydantic-evals==0.2.13; extra == 'evals'
52
52
  Provides-Extra: google
53
53
  Requires-Dist: google-genai>=1.15.0; extra == 'google'
54
54
  Provides-Extra: groq
@@ -5,7 +5,7 @@ pydantic_ai/_agent_graph.py,sha256=_7iJLLpOwCqViTE2BGTZfI42zdmsz7QPhgP0hdclsvg,3
5
5
  pydantic_ai/_cli.py,sha256=kc9UxGjYsKK0IR4No-V5BGiAtq2fY6eZZ9rBkAdHWOM,12948
6
6
  pydantic_ai/_function_schema.py,sha256=Ciah-kyw-QiMeM8PtIe4DhOAlmyCZf98D1U0FIdl930,10563
7
7
  pydantic_ai/_griffe.py,sha256=Sf_DisE9k2TA0VFeVIK2nf1oOct5MygW86PBCACJkFA,5244
8
- pydantic_ai/_output.py,sha256=PSx8xbgS4kxb6b7b_oWMcB8mmZ1jU8IEjV8zgxkEIzM,16775
8
+ pydantic_ai/_output.py,sha256=MxonK-JPfgSw1nboIQMlnGb5WloTX8WkI9gcWAeCiPI,16798
9
9
  pydantic_ai/_parts_manager.py,sha256=c0Gj29FH8K20AmxIr7MY8_SQVdb7SRIRcJYTQVmVYgc,12204
10
10
  pydantic_ai/_system_prompt.py,sha256=602c2jyle2R_SesOrITBDETZqsLk4BZ8Cbo8yEhmx04,1120
11
11
  pydantic_ai/_utils.py,sha256=XfZ7mZmrv5ZsU3DwjwLXwmbVNTQrgX_kIL9SIfatg90,10456
@@ -19,7 +19,7 @@ pydantic_ai/messages.py,sha256=K5zHLOgTLCr2AlqPYA_-WyDJ9B-rAvSiylATbzvZSfc,32410
19
19
  pydantic_ai/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
20
  pydantic_ai/result.py,sha256=YlcR0QAQIejz3fbZ50zYfHKIZco0dwmnZTxytV-n3oM,24609
21
21
  pydantic_ai/settings.py,sha256=U2XzZ9y1fIi_L6yCGTugZRxfk7_01rk5GKSgFqySHL4,3520
22
- pydantic_ai/tools.py,sha256=m74jwTEr-FNi-seWjAujVrVEMemuIqihAeyKcMcQBwk,16844
22
+ pydantic_ai/tools.py,sha256=a6sZv_YcGYbc2A9mhnlR0UoQp9Mt-uSrwbvfhat6mbw,16867
23
23
  pydantic_ai/usage.py,sha256=35YPmItlzfNOwP35Rhh0qBUOlg5On5rUE7xqHQWrpaU,5596
24
24
  pydantic_ai/common_tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
25
  pydantic_ai/common_tools/duckduckgo.py,sha256=Ty9tu1rCwMfGKgz1JAaC2q_4esmL6QvpkHQUN8F0Ecc,2152
@@ -30,12 +30,12 @@ pydantic_ai/models/bedrock.py,sha256=Y_JMGe09JlFrfS2U3m39EGLViFbJ_WSMljZCQpxSuEI
30
30
  pydantic_ai/models/cohere.py,sha256=bQLTQguqVXkzkPgWmMncrxApO9CQ7YtgrmFwa057g7g,12116
31
31
  pydantic_ai/models/fallback.py,sha256=idOYGMo3CZzpCBT8DDiuPAAgnV2jzluDUq3ESb3KteM,4981
32
32
  pydantic_ai/models/function.py,sha256=rnihsyakyieCGbEyxfqzvoBHnR_3LJn4x6DXQqdAAM4,11458
33
- pydantic_ai/models/gemini.py,sha256=y-Yw6bPnNt1FcEvisAuryqZGtKOk5obO2LRzkSOGogM,35483
34
- pydantic_ai/models/google.py,sha256=cGgYkOGlBLb_IH3LFP_Y8Iprg5Y2SKOIOEmCWmvsVeA,20967
33
+ pydantic_ai/models/gemini.py,sha256=27y4JPGU0EJzGpYZpv6WlAYzHdW_1oD4fRISjoQMKW0,35823
34
+ pydantic_ai/models/google.py,sha256=6aHUz5lnzA2cxAhF5l9ff5vx0ubtdIUsjHVUyKFjjCM,20991
35
35
  pydantic_ai/models/groq.py,sha256=MVJO8DQbgO7NlRA898hTdFnKz1Y42c31u8BDoYDxGIg,17848
36
36
  pydantic_ai/models/instrumented.py,sha256=Y3SxAlP9cCX_Ch02c8qN9mrWMY9_tuyj6zMeN5Gz-W0,12356
37
37
  pydantic_ai/models/mistral.py,sha256=pTywq_QCjjAlRC5uTQ9DQeONH0Fsc1cYUVku9BW21Wk,29614
38
- pydantic_ai/models/openai.py,sha256=QlbYQQr6vgy5peS0nLZnAtQLBoGDFvvAlDNX_WGNeGI,44466
38
+ pydantic_ai/models/openai.py,sha256=tsuHg-Rywlv9LtnW3Wad6W1pr4Ogr-pca2q14ZhTiPU,44556
39
39
  pydantic_ai/models/test.py,sha256=Jlq-YQ9dhzENgmBMVerZpM4L-I2aPf7HH7ifIncyDlE,17010
40
40
  pydantic_ai/models/wrapper.py,sha256=43ntRkTF7rVBYLC-Ihdo1fkwpeveOpA_1fXe1fd3W9Y,1690
41
41
  pydantic_ai/profiles/__init__.py,sha256=uO_f1kSqrnXuO0x5U0EHTTMRYcmOiOoa-tS1OZppxBk,1426
@@ -66,8 +66,8 @@ pydantic_ai/providers/mistral.py,sha256=EIUSENjFuGzBhvbdrarUTM4VPkesIMnZrzfnEKHO
66
66
  pydantic_ai/providers/openai.py,sha256=7iGij0EaFylab7dTZAZDgXr78tr-HsZrn9EI9AkWBNQ,3091
67
67
  pydantic_ai/providers/openrouter.py,sha256=NXjNdnlXIBrBMMqbzcWQnowXOuZh4NHikXenBn5h3mc,4061
68
68
  pydantic_ai/providers/together.py,sha256=zFVSMSm5jXbpkNouvBOTjWrPmlPpCp6sQS5LMSyVjrQ,3482
69
- pydantic_ai_slim-0.2.12.dist-info/METADATA,sha256=bQm36Co0UI5lXFfgkrLP4d30YhZRQlawSwiBhLt6hl0,3850
70
- pydantic_ai_slim-0.2.12.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
71
- pydantic_ai_slim-0.2.12.dist-info/entry_points.txt,sha256=kbKxe2VtDCYS06hsI7P3uZGxcVC08-FPt1rxeiMpIps,50
72
- pydantic_ai_slim-0.2.12.dist-info/licenses/LICENSE,sha256=vA6Jc482lEyBBuGUfD1pYx-cM7jxvLYOxPidZ30t_PQ,1100
73
- pydantic_ai_slim-0.2.12.dist-info/RECORD,,
69
+ pydantic_ai_slim-0.2.13.dist-info/METADATA,sha256=Lvl-Ez42y8jr_iHjI7XvkOd5WYCGNVTREgnh699XV8k,3850
70
+ pydantic_ai_slim-0.2.13.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
71
+ pydantic_ai_slim-0.2.13.dist-info/entry_points.txt,sha256=kbKxe2VtDCYS06hsI7P3uZGxcVC08-FPt1rxeiMpIps,50
72
+ pydantic_ai_slim-0.2.13.dist-info/licenses/LICENSE,sha256=vA6Jc482lEyBBuGUfD1pYx-cM7jxvLYOxPidZ30t_PQ,1100
73
+ pydantic_ai_slim-0.2.13.dist-info/RECORD,,