pydantic-ai-slim 0.2.8__tar.gz → 0.2.9__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.
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/PKG-INFO +4 -4
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/_cli.py +1 -1
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/models/gemini.py +33 -16
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/models/google.py +7 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/.gitignore +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/LICENSE +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/README.md +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/__init__.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/__main__.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/_a2a.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/_agent_graph.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/_griffe.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/_output.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/_parts_manager.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/_pydantic.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/_system_prompt.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/_utils.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/agent.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/common_tools/__init__.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/common_tools/duckduckgo.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/common_tools/tavily.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/direct.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/exceptions.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/format_as_xml.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/format_prompt.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/mcp.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/messages.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/models/__init__.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/models/_json_schema.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/models/anthropic.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/models/bedrock.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/models/cohere.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/models/fallback.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/models/function.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/models/groq.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/models/instrumented.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/models/mistral.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/models/openai.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/models/test.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/models/wrapper.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/providers/__init__.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/providers/anthropic.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/providers/azure.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/providers/bedrock.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/providers/cohere.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/providers/deepseek.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/providers/google.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/providers/google_gla.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/providers/google_vertex.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/providers/groq.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/providers/mistral.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/providers/openai.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/providers/openrouter.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/py.typed +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/result.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/settings.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/tools.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pydantic_ai/usage.py +0 -0
- {pydantic_ai_slim-0.2.8 → pydantic_ai_slim-0.2.9}/pyproject.toml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pydantic-ai-slim
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.9
|
|
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.
|
|
33
|
+
Requires-Dist: pydantic-graph==0.2.9
|
|
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.
|
|
37
|
+
Requires-Dist: fasta2a==0.2.9; extra == 'a2a'
|
|
38
38
|
Provides-Extra: anthropic
|
|
39
39
|
Requires-Dist: anthropic>=0.49.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.
|
|
51
|
+
Requires-Dist: pydantic-evals==0.2.9; extra == 'evals'
|
|
52
52
|
Provides-Extra: google
|
|
53
53
|
Requires-Dist: google-genai>=1.15.0; extra == 'google'
|
|
54
54
|
Provides-Extra: groq
|
|
@@ -284,7 +284,7 @@ async def ask_agent(
|
|
|
284
284
|
stack.enter_context(live) # entering multiple times is idempotent
|
|
285
285
|
|
|
286
286
|
async for content in handle_stream.stream_output(debounce_by=None):
|
|
287
|
-
live.update(Markdown(content, code_theme=code_theme))
|
|
287
|
+
live.update(Markdown(str(content), code_theme=code_theme))
|
|
288
288
|
|
|
289
289
|
assert agent_run.result is not None
|
|
290
290
|
return agent_run.result.all_messages()
|
|
@@ -80,6 +80,7 @@ class GeminiModelSettings(ModelSettings, total=False):
|
|
|
80
80
|
"""
|
|
81
81
|
|
|
82
82
|
gemini_safety_settings: list[GeminiSafetySettings]
|
|
83
|
+
"""Safety settings options for Gemini model request."""
|
|
83
84
|
|
|
84
85
|
gemini_thinking_config: ThinkingConfig
|
|
85
86
|
"""Thinking is "on" by default in both the API and AI Studio.
|
|
@@ -93,6 +94,12 @@ class GeminiModelSettings(ModelSettings, total=False):
|
|
|
93
94
|
See more about it on <https://ai.google.dev/gemini-api/docs/thinking>.
|
|
94
95
|
"""
|
|
95
96
|
|
|
97
|
+
gemini_labels: dict[str, str]
|
|
98
|
+
"""User-defined metadata to break down billed charges. Only supported by the Vertex AI provider.
|
|
99
|
+
|
|
100
|
+
See the [Gemini API docs](https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/add-labels-to-api-calls) for use cases and limitations.
|
|
101
|
+
"""
|
|
102
|
+
|
|
96
103
|
|
|
97
104
|
@dataclass(init=False)
|
|
98
105
|
class GeminiModel(Model):
|
|
@@ -223,25 +230,17 @@ class GeminiModel(Model):
|
|
|
223
230
|
if tool_config is not None:
|
|
224
231
|
request_data['toolConfig'] = tool_config
|
|
225
232
|
|
|
226
|
-
generation_config
|
|
227
|
-
if model_settings:
|
|
228
|
-
if (max_tokens := model_settings.get('max_tokens')) is not None:
|
|
229
|
-
generation_config['max_output_tokens'] = max_tokens
|
|
230
|
-
if (temperature := model_settings.get('temperature')) is not None:
|
|
231
|
-
generation_config['temperature'] = temperature
|
|
232
|
-
if (top_p := model_settings.get('top_p')) is not None:
|
|
233
|
-
generation_config['top_p'] = top_p
|
|
234
|
-
if (presence_penalty := model_settings.get('presence_penalty')) is not None:
|
|
235
|
-
generation_config['presence_penalty'] = presence_penalty
|
|
236
|
-
if (frequency_penalty := model_settings.get('frequency_penalty')) is not None:
|
|
237
|
-
generation_config['frequency_penalty'] = frequency_penalty
|
|
238
|
-
if (thinkingConfig := model_settings.get('gemini_thinking_config')) is not None:
|
|
239
|
-
generation_config['thinking_config'] = thinkingConfig # pragma: no cover
|
|
240
|
-
if (gemini_safety_settings := model_settings.get('gemini_safety_settings')) is not None:
|
|
241
|
-
request_data['safetySettings'] = gemini_safety_settings
|
|
233
|
+
generation_config = _settings_to_generation_config(model_settings)
|
|
242
234
|
if generation_config:
|
|
243
235
|
request_data['generationConfig'] = generation_config
|
|
244
236
|
|
|
237
|
+
if gemini_safety_settings := model_settings.get('gemini_safety_settings'):
|
|
238
|
+
request_data['safetySettings'] = gemini_safety_settings
|
|
239
|
+
|
|
240
|
+
if gemini_labels := model_settings.get('gemini_labels'):
|
|
241
|
+
if self._system == 'google-vertex':
|
|
242
|
+
request_data['labels'] = gemini_labels
|
|
243
|
+
|
|
245
244
|
headers = {'Content-Type': 'application/json', 'User-Agent': get_user_agent()}
|
|
246
245
|
url = f'/{self._model_name}:{"streamGenerateContent" if streamed else "generateContent"}'
|
|
247
246
|
|
|
@@ -362,6 +361,23 @@ class GeminiModel(Model):
|
|
|
362
361
|
return content
|
|
363
362
|
|
|
364
363
|
|
|
364
|
+
def _settings_to_generation_config(model_settings: GeminiModelSettings) -> _GeminiGenerationConfig:
|
|
365
|
+
config: _GeminiGenerationConfig = {}
|
|
366
|
+
if (max_tokens := model_settings.get('max_tokens')) is not None:
|
|
367
|
+
config['max_output_tokens'] = max_tokens
|
|
368
|
+
if (temperature := model_settings.get('temperature')) is not None:
|
|
369
|
+
config['temperature'] = temperature
|
|
370
|
+
if (top_p := model_settings.get('top_p')) is not None:
|
|
371
|
+
config['top_p'] = top_p
|
|
372
|
+
if (presence_penalty := model_settings.get('presence_penalty')) is not None:
|
|
373
|
+
config['presence_penalty'] = presence_penalty
|
|
374
|
+
if (frequency_penalty := model_settings.get('frequency_penalty')) is not None:
|
|
375
|
+
config['frequency_penalty'] = frequency_penalty
|
|
376
|
+
if (thinkingConfig := model_settings.get('gemini_thinking_config')) is not None:
|
|
377
|
+
config['thinking_config'] = thinkingConfig # pragma: no cover
|
|
378
|
+
return config
|
|
379
|
+
|
|
380
|
+
|
|
365
381
|
class AuthProtocol(Protocol):
|
|
366
382
|
"""Abstract definition for Gemini authentication."""
|
|
367
383
|
|
|
@@ -483,6 +499,7 @@ class _GeminiRequest(TypedDict):
|
|
|
483
499
|
<https://ai.google.dev/gemini-api/docs/system-instructions?lang=rest>
|
|
484
500
|
"""
|
|
485
501
|
generationConfig: NotRequired[_GeminiGenerationConfig]
|
|
502
|
+
labels: NotRequired[dict[str, str]]
|
|
486
503
|
|
|
487
504
|
|
|
488
505
|
class GeminiSafetySettings(TypedDict):
|
|
@@ -115,6 +115,12 @@ class GoogleModelSettings(ModelSettings, total=False):
|
|
|
115
115
|
See <https://ai.google.dev/gemini-api/docs/thinking> for more information.
|
|
116
116
|
"""
|
|
117
117
|
|
|
118
|
+
google_labels: dict[str, str]
|
|
119
|
+
"""User-defined metadata to break down billed charges. Only supported by the Vertex AI API.
|
|
120
|
+
|
|
121
|
+
See the [Gemini API docs](https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/add-labels-to-api-calls) for use cases and limitations.
|
|
122
|
+
"""
|
|
123
|
+
|
|
118
124
|
|
|
119
125
|
@dataclass(init=False)
|
|
120
126
|
class GoogleModel(Model):
|
|
@@ -269,6 +275,7 @@ class GoogleModel(Model):
|
|
|
269
275
|
frequency_penalty=model_settings.get('frequency_penalty'),
|
|
270
276
|
safety_settings=model_settings.get('google_safety_settings'),
|
|
271
277
|
thinking_config=model_settings.get('google_thinking_config'),
|
|
278
|
+
labels=model_settings.get('google_labels'),
|
|
272
279
|
tools=cast(ToolListUnionDict, tools),
|
|
273
280
|
tool_config=tool_config,
|
|
274
281
|
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|