pydantic-ai-slim 0.5.0__tar.gz → 0.6.0__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-slim might be problematic. Click here for more details.
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/PKG-INFO +5 -5
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/_agent_graph.py +1 -1
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/agent.py +19 -246
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/exceptions.py +2 -2
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/models/__init__.py +2 -6
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/models/anthropic.py +1 -1
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/models/bedrock.py +1 -1
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/models/cohere.py +1 -1
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/models/gemini.py +5 -4
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/models/google.py +4 -2
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/models/groq.py +1 -1
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/models/instrumented.py +2 -6
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/models/mistral.py +1 -1
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/models/openai.py +2 -2
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/profiles/_json_schema.py +4 -3
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/providers/__init__.py +4 -4
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/providers/google.py +9 -6
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/providers/google_gla.py +2 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/providers/google_vertex.py +2 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/result.py +13 -82
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pyproject.toml +5 -4
- pydantic_ai_slim-0.5.0/pydantic_ai/format_as_xml.py +0 -9
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/.gitignore +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/LICENSE +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/README.md +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/__init__.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/__main__.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/_a2a.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/_cli.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/_function_schema.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/_griffe.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/_mcp.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/_output.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/_parts_manager.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/_run_context.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/_system_prompt.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/_thinking_part.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/_tool_manager.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/_utils.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/ag_ui.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/common_tools/__init__.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/common_tools/duckduckgo.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/common_tools/tavily.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/direct.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/ext/__init__.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/ext/aci.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/ext/langchain.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/format_prompt.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/mcp.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/messages.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/models/fallback.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/models/function.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/models/huggingface.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/models/mcp_sampling.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/models/test.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/models/wrapper.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/output.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/profiles/__init__.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/profiles/amazon.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/profiles/anthropic.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/profiles/cohere.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/profiles/deepseek.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/profiles/google.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/profiles/grok.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/profiles/meta.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/profiles/mistral.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/profiles/moonshotai.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/profiles/openai.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/profiles/qwen.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/providers/anthropic.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/providers/azure.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/providers/bedrock.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/providers/cohere.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/providers/deepseek.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/providers/fireworks.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/providers/github.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/providers/grok.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/providers/groq.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/providers/heroku.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/providers/huggingface.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/providers/mistral.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/providers/moonshotai.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/providers/openai.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/providers/openrouter.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/providers/together.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/providers/vercel.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/py.typed +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/retries.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/settings.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/tools.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/toolsets/__init__.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/toolsets/abstract.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/toolsets/combined.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/toolsets/deferred.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/toolsets/filtered.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/toolsets/function.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/toolsets/prefixed.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/toolsets/prepared.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/toolsets/renamed.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/toolsets/wrapper.py +0 -0
- {pydantic_ai_slim-0.5.0 → pydantic_ai_slim-0.6.0}/pydantic_ai/usage.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pydantic-ai-slim
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.0
|
|
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>, Douwe Maan <douwe@pydantic.dev>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -30,7 +30,7 @@ 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.
|
|
33
|
+
Requires-Dist: pydantic-graph==0.6.0
|
|
34
34
|
Requires-Dist: pydantic>=2.10
|
|
35
35
|
Requires-Dist: typing-inspection>=0.4.0
|
|
36
36
|
Provides-Extra: a2a
|
|
@@ -39,7 +39,7 @@ Provides-Extra: ag-ui
|
|
|
39
39
|
Requires-Dist: ag-ui-protocol>=0.1.8; extra == 'ag-ui'
|
|
40
40
|
Requires-Dist: starlette>=0.45.3; extra == 'ag-ui'
|
|
41
41
|
Provides-Extra: anthropic
|
|
42
|
-
Requires-Dist: anthropic>=0.
|
|
42
|
+
Requires-Dist: anthropic>=0.61.0; extra == 'anthropic'
|
|
43
43
|
Provides-Extra: bedrock
|
|
44
44
|
Requires-Dist: boto3>=1.37.24; extra == 'bedrock'
|
|
45
45
|
Provides-Extra: cli
|
|
@@ -51,9 +51,9 @@ Requires-Dist: cohere>=5.16.0; (platform_system != 'Emscripten') and extra == 'c
|
|
|
51
51
|
Provides-Extra: duckduckgo
|
|
52
52
|
Requires-Dist: ddgs>=9.0.0; extra == 'duckduckgo'
|
|
53
53
|
Provides-Extra: evals
|
|
54
|
-
Requires-Dist: pydantic-evals==0.
|
|
54
|
+
Requires-Dist: pydantic-evals==0.6.0; extra == 'evals'
|
|
55
55
|
Provides-Extra: google
|
|
56
|
-
Requires-Dist: google-genai>=1.
|
|
56
|
+
Requires-Dist: google-genai>=1.28.0; extra == 'google'
|
|
57
57
|
Provides-Extra: groq
|
|
58
58
|
Requires-Dist: groq>=0.19.0; extra == 'groq'
|
|
59
59
|
Provides-Extra: huggingface
|
|
@@ -620,7 +620,7 @@ async def process_function_tools( # noqa: C901
|
|
|
620
620
|
result_data = await tool_manager.handle_call(call)
|
|
621
621
|
except exceptions.UnexpectedModelBehavior as e:
|
|
622
622
|
ctx.state.increment_retries(ctx.deps.max_result_retries, e)
|
|
623
|
-
raise e # pragma: no cover
|
|
623
|
+
raise e # pragma: lax no cover
|
|
624
624
|
except ToolRetryError as e:
|
|
625
625
|
ctx.state.increment_retries(ctx.deps.max_result_retries, e)
|
|
626
626
|
yield _messages.FunctionToolCallEvent(call)
|
|
@@ -151,8 +151,6 @@ class Agent(Generic[AgentDepsT, OutputDataT]):
|
|
|
151
151
|
_instrument_default: ClassVar[InstrumentationSettings | bool] = False
|
|
152
152
|
|
|
153
153
|
_deps_type: type[AgentDepsT] = dataclasses.field(repr=False)
|
|
154
|
-
_deprecated_result_tool_name: str | None = dataclasses.field(repr=False)
|
|
155
|
-
_deprecated_result_tool_description: str | None = dataclasses.field(repr=False)
|
|
156
154
|
_output_schema: _output.BaseOutputSchema[OutputDataT] = dataclasses.field(repr=False)
|
|
157
155
|
_output_validators: list[_output.OutputValidator[AgentDepsT, OutputDataT]] = dataclasses.field(repr=False)
|
|
158
156
|
_instructions: str | None = dataclasses.field(repr=False)
|
|
@@ -199,44 +197,13 @@ class Agent(Generic[AgentDepsT, OutputDataT]):
|
|
|
199
197
|
history_processors: Sequence[HistoryProcessor[AgentDepsT]] | None = None,
|
|
200
198
|
) -> None: ...
|
|
201
199
|
|
|
202
|
-
@overload
|
|
203
|
-
@deprecated(
|
|
204
|
-
'`result_type`, `result_tool_name` & `result_tool_description` are deprecated, use `output_type` instead. `result_retries` is deprecated, use `output_retries` instead.'
|
|
205
|
-
)
|
|
206
|
-
def __init__(
|
|
207
|
-
self,
|
|
208
|
-
model: models.Model | models.KnownModelName | str | None = None,
|
|
209
|
-
*,
|
|
210
|
-
result_type: type[OutputDataT] = str,
|
|
211
|
-
instructions: str
|
|
212
|
-
| _system_prompt.SystemPromptFunc[AgentDepsT]
|
|
213
|
-
| Sequence[str | _system_prompt.SystemPromptFunc[AgentDepsT]]
|
|
214
|
-
| None = None,
|
|
215
|
-
system_prompt: str | Sequence[str] = (),
|
|
216
|
-
deps_type: type[AgentDepsT] = NoneType,
|
|
217
|
-
name: str | None = None,
|
|
218
|
-
model_settings: ModelSettings | None = None,
|
|
219
|
-
retries: int = 1,
|
|
220
|
-
result_tool_name: str = _output.DEFAULT_OUTPUT_TOOL_NAME,
|
|
221
|
-
result_tool_description: str | None = None,
|
|
222
|
-
result_retries: int | None = None,
|
|
223
|
-
tools: Sequence[Tool[AgentDepsT] | ToolFuncEither[AgentDepsT, ...]] = (),
|
|
224
|
-
prepare_tools: ToolsPrepareFunc[AgentDepsT] | None = None,
|
|
225
|
-
prepare_output_tools: ToolsPrepareFunc[AgentDepsT] | None = None,
|
|
226
|
-
toolsets: Sequence[AbstractToolset[AgentDepsT]] | None = None,
|
|
227
|
-
defer_model_check: bool = False,
|
|
228
|
-
end_strategy: EndStrategy = 'early',
|
|
229
|
-
instrument: InstrumentationSettings | bool | None = None,
|
|
230
|
-
history_processors: Sequence[HistoryProcessor[AgentDepsT]] | None = None,
|
|
231
|
-
) -> None: ...
|
|
232
|
-
|
|
233
200
|
@overload
|
|
234
201
|
@deprecated('`mcp_servers` is deprecated, use `toolsets` instead.')
|
|
235
202
|
def __init__(
|
|
236
203
|
self,
|
|
237
204
|
model: models.Model | models.KnownModelName | str | None = None,
|
|
238
205
|
*,
|
|
239
|
-
|
|
206
|
+
output_type: OutputSpec[OutputDataT] = str,
|
|
240
207
|
instructions: str
|
|
241
208
|
| _system_prompt.SystemPromptFunc[AgentDepsT]
|
|
242
209
|
| Sequence[str | _system_prompt.SystemPromptFunc[AgentDepsT]]
|
|
@@ -246,9 +213,7 @@ class Agent(Generic[AgentDepsT, OutputDataT]):
|
|
|
246
213
|
name: str | None = None,
|
|
247
214
|
model_settings: ModelSettings | None = None,
|
|
248
215
|
retries: int = 1,
|
|
249
|
-
|
|
250
|
-
result_tool_description: str | None = None,
|
|
251
|
-
result_retries: int | None = None,
|
|
216
|
+
output_retries: int | None = None,
|
|
252
217
|
tools: Sequence[Tool[AgentDepsT] | ToolFuncEither[AgentDepsT, ...]] = (),
|
|
253
218
|
prepare_tools: ToolsPrepareFunc[AgentDepsT] | None = None,
|
|
254
219
|
prepare_output_tools: ToolsPrepareFunc[AgentDepsT] | None = None,
|
|
@@ -263,8 +228,7 @@ class Agent(Generic[AgentDepsT, OutputDataT]):
|
|
|
263
228
|
self,
|
|
264
229
|
model: models.Model | models.KnownModelName | str | None = None,
|
|
265
230
|
*,
|
|
266
|
-
|
|
267
|
-
output_type: Any = str,
|
|
231
|
+
output_type: OutputSpec[OutputDataT] = str,
|
|
268
232
|
instructions: str
|
|
269
233
|
| _system_prompt.SystemPromptFunc[AgentDepsT]
|
|
270
234
|
| Sequence[str | _system_prompt.SystemPromptFunc[AgentDepsT]]
|
|
@@ -341,42 +305,10 @@ class Agent(Generic[AgentDepsT, OutputDataT]):
|
|
|
341
305
|
self.name = name
|
|
342
306
|
self.model_settings = model_settings
|
|
343
307
|
|
|
344
|
-
if 'result_type' in _deprecated_kwargs:
|
|
345
|
-
if output_type is not str: # pragma: no cover
|
|
346
|
-
raise TypeError('`result_type` and `output_type` cannot be set at the same time.')
|
|
347
|
-
warnings.warn('`result_type` is deprecated, use `output_type` instead', DeprecationWarning, stacklevel=2)
|
|
348
|
-
output_type = _deprecated_kwargs.pop('result_type')
|
|
349
|
-
|
|
350
308
|
self.output_type = output_type
|
|
351
|
-
|
|
352
309
|
self.instrument = instrument
|
|
353
|
-
|
|
354
310
|
self._deps_type = deps_type
|
|
355
311
|
|
|
356
|
-
self._deprecated_result_tool_name = _deprecated_kwargs.pop('result_tool_name', None)
|
|
357
|
-
if self._deprecated_result_tool_name is not None:
|
|
358
|
-
warnings.warn(
|
|
359
|
-
'`result_tool_name` is deprecated, use `output_type` with `ToolOutput` instead',
|
|
360
|
-
DeprecationWarning,
|
|
361
|
-
stacklevel=2,
|
|
362
|
-
)
|
|
363
|
-
|
|
364
|
-
self._deprecated_result_tool_description = _deprecated_kwargs.pop('result_tool_description', None)
|
|
365
|
-
if self._deprecated_result_tool_description is not None:
|
|
366
|
-
warnings.warn(
|
|
367
|
-
'`result_tool_description` is deprecated, use `output_type` with `ToolOutput` instead',
|
|
368
|
-
DeprecationWarning,
|
|
369
|
-
stacklevel=2,
|
|
370
|
-
)
|
|
371
|
-
result_retries = _deprecated_kwargs.pop('result_retries', None)
|
|
372
|
-
if result_retries is not None:
|
|
373
|
-
if output_retries is not None: # pragma: no cover
|
|
374
|
-
raise TypeError('`output_retries` and `result_retries` cannot be set at the same time.')
|
|
375
|
-
warnings.warn(
|
|
376
|
-
'`result_retries` is deprecated, use `max_result_retries` instead', DeprecationWarning, stacklevel=2
|
|
377
|
-
)
|
|
378
|
-
output_retries = result_retries
|
|
379
|
-
|
|
380
312
|
if mcp_servers := _deprecated_kwargs.pop('mcp_servers', None):
|
|
381
313
|
if toolsets is not None: # pragma: no cover
|
|
382
314
|
raise TypeError('`mcp_servers` and `toolsets` cannot be set at the same time.')
|
|
@@ -389,12 +321,7 @@ class Agent(Generic[AgentDepsT, OutputDataT]):
|
|
|
389
321
|
self.model.profile.default_structured_output_mode if isinstance(self.model, models.Model) else None
|
|
390
322
|
)
|
|
391
323
|
|
|
392
|
-
self._output_schema = _output.OutputSchema[OutputDataT].build(
|
|
393
|
-
output_type,
|
|
394
|
-
default_mode=default_output_mode,
|
|
395
|
-
name=self._deprecated_result_tool_name,
|
|
396
|
-
description=self._deprecated_result_tool_description,
|
|
397
|
-
)
|
|
324
|
+
self._output_schema = _output.OutputSchema[OutputDataT].build(output_type, default_mode=default_output_mode)
|
|
398
325
|
self._output_validators = []
|
|
399
326
|
|
|
400
327
|
self._instructions = ''
|
|
@@ -472,23 +399,6 @@ class Agent(Generic[AgentDepsT, OutputDataT]):
|
|
|
472
399
|
toolsets: Sequence[AbstractToolset[AgentDepsT]] | None = None,
|
|
473
400
|
) -> AgentRunResult[RunOutputDataT]: ...
|
|
474
401
|
|
|
475
|
-
@overload
|
|
476
|
-
@deprecated('`result_type` is deprecated, use `output_type` instead.')
|
|
477
|
-
async def run(
|
|
478
|
-
self,
|
|
479
|
-
user_prompt: str | Sequence[_messages.UserContent] | None = None,
|
|
480
|
-
*,
|
|
481
|
-
result_type: type[RunOutputDataT],
|
|
482
|
-
message_history: list[_messages.ModelMessage] | None = None,
|
|
483
|
-
model: models.Model | models.KnownModelName | str | None = None,
|
|
484
|
-
deps: AgentDepsT = None,
|
|
485
|
-
model_settings: ModelSettings | None = None,
|
|
486
|
-
usage_limits: _usage.UsageLimits | None = None,
|
|
487
|
-
usage: _usage.Usage | None = None,
|
|
488
|
-
infer_name: bool = True,
|
|
489
|
-
toolsets: Sequence[AbstractToolset[AgentDepsT]] | None = None,
|
|
490
|
-
) -> AgentRunResult[RunOutputDataT]: ...
|
|
491
|
-
|
|
492
402
|
async def run(
|
|
493
403
|
self,
|
|
494
404
|
user_prompt: str | Sequence[_messages.UserContent] | None = None,
|
|
@@ -540,12 +450,6 @@ class Agent(Generic[AgentDepsT, OutputDataT]):
|
|
|
540
450
|
if infer_name and self.name is None:
|
|
541
451
|
self._infer_name(inspect.currentframe())
|
|
542
452
|
|
|
543
|
-
if 'result_type' in _deprecated_kwargs: # pragma: no cover
|
|
544
|
-
if output_type is not str:
|
|
545
|
-
raise TypeError('`result_type` and `output_type` cannot be set at the same time.')
|
|
546
|
-
warnings.warn('`result_type` is deprecated, use `output_type` instead.', DeprecationWarning, stacklevel=2)
|
|
547
|
-
output_type = _deprecated_kwargs.pop('result_type')
|
|
548
|
-
|
|
549
453
|
_utils.validate_empty_kwargs(_deprecated_kwargs)
|
|
550
454
|
|
|
551
455
|
async with self.iter(
|
|
@@ -599,23 +503,6 @@ class Agent(Generic[AgentDepsT, OutputDataT]):
|
|
|
599
503
|
**_deprecated_kwargs: Never,
|
|
600
504
|
) -> AbstractAsyncContextManager[AgentRun[AgentDepsT, RunOutputDataT]]: ...
|
|
601
505
|
|
|
602
|
-
@overload
|
|
603
|
-
@deprecated('`result_type` is deprecated, use `output_type` instead.')
|
|
604
|
-
def iter(
|
|
605
|
-
self,
|
|
606
|
-
user_prompt: str | Sequence[_messages.UserContent] | None = None,
|
|
607
|
-
*,
|
|
608
|
-
result_type: type[RunOutputDataT],
|
|
609
|
-
message_history: list[_messages.ModelMessage] | None = None,
|
|
610
|
-
model: models.Model | models.KnownModelName | str | None = None,
|
|
611
|
-
deps: AgentDepsT = None,
|
|
612
|
-
model_settings: ModelSettings | None = None,
|
|
613
|
-
usage_limits: _usage.UsageLimits | None = None,
|
|
614
|
-
usage: _usage.Usage | None = None,
|
|
615
|
-
infer_name: bool = True,
|
|
616
|
-
toolsets: Sequence[AbstractToolset[AgentDepsT]] | None = None,
|
|
617
|
-
) -> AbstractAsyncContextManager[AgentRun[AgentDepsT, Any]]: ...
|
|
618
|
-
|
|
619
506
|
@asynccontextmanager
|
|
620
507
|
async def iter(
|
|
621
508
|
self,
|
|
@@ -714,12 +601,6 @@ class Agent(Generic[AgentDepsT, OutputDataT]):
|
|
|
714
601
|
model_used = self._get_model(model)
|
|
715
602
|
del model
|
|
716
603
|
|
|
717
|
-
if 'result_type' in _deprecated_kwargs: # pragma: no cover
|
|
718
|
-
if output_type is not str:
|
|
719
|
-
raise TypeError('`result_type` and `output_type` cannot be set at the same time.')
|
|
720
|
-
warnings.warn('`result_type` is deprecated, use `output_type` instead.', DeprecationWarning, stacklevel=2)
|
|
721
|
-
output_type = _deprecated_kwargs.pop('result_type')
|
|
722
|
-
|
|
723
604
|
_utils.validate_empty_kwargs(_deprecated_kwargs)
|
|
724
605
|
|
|
725
606
|
deps = self._get_deps(deps)
|
|
@@ -910,23 +791,6 @@ class Agent(Generic[AgentDepsT, OutputDataT]):
|
|
|
910
791
|
toolsets: Sequence[AbstractToolset[AgentDepsT]] | None = None,
|
|
911
792
|
) -> AgentRunResult[RunOutputDataT]: ...
|
|
912
793
|
|
|
913
|
-
@overload
|
|
914
|
-
@deprecated('`result_type` is deprecated, use `output_type` instead.')
|
|
915
|
-
def run_sync(
|
|
916
|
-
self,
|
|
917
|
-
user_prompt: str | Sequence[_messages.UserContent] | None = None,
|
|
918
|
-
*,
|
|
919
|
-
result_type: type[RunOutputDataT],
|
|
920
|
-
message_history: list[_messages.ModelMessage] | None = None,
|
|
921
|
-
model: models.Model | models.KnownModelName | str | None = None,
|
|
922
|
-
deps: AgentDepsT = None,
|
|
923
|
-
model_settings: ModelSettings | None = None,
|
|
924
|
-
usage_limits: _usage.UsageLimits | None = None,
|
|
925
|
-
usage: _usage.Usage | None = None,
|
|
926
|
-
infer_name: bool = True,
|
|
927
|
-
toolsets: Sequence[AbstractToolset[AgentDepsT]] | None = None,
|
|
928
|
-
) -> AgentRunResult[RunOutputDataT]: ...
|
|
929
|
-
|
|
930
794
|
def run_sync(
|
|
931
795
|
self,
|
|
932
796
|
user_prompt: str | Sequence[_messages.UserContent] | None = None,
|
|
@@ -977,12 +841,6 @@ class Agent(Generic[AgentDepsT, OutputDataT]):
|
|
|
977
841
|
if infer_name and self.name is None:
|
|
978
842
|
self._infer_name(inspect.currentframe())
|
|
979
843
|
|
|
980
|
-
if 'result_type' in _deprecated_kwargs: # pragma: no cover
|
|
981
|
-
if output_type is not str:
|
|
982
|
-
raise TypeError('`result_type` and `output_type` cannot be set at the same time.')
|
|
983
|
-
warnings.warn('`result_type` is deprecated, use `output_type` instead.', DeprecationWarning, stacklevel=2)
|
|
984
|
-
output_type = _deprecated_kwargs.pop('result_type')
|
|
985
|
-
|
|
986
844
|
_utils.validate_empty_kwargs(_deprecated_kwargs)
|
|
987
845
|
|
|
988
846
|
return get_event_loop().run_until_complete(
|
|
@@ -1031,25 +889,8 @@ class Agent(Generic[AgentDepsT, OutputDataT]):
|
|
|
1031
889
|
toolsets: Sequence[AbstractToolset[AgentDepsT]] | None = None,
|
|
1032
890
|
) -> AbstractAsyncContextManager[result.StreamedRunResult[AgentDepsT, RunOutputDataT]]: ...
|
|
1033
891
|
|
|
1034
|
-
@overload
|
|
1035
|
-
@deprecated('`result_type` is deprecated, use `output_type` instead.')
|
|
1036
|
-
def run_stream(
|
|
1037
|
-
self,
|
|
1038
|
-
user_prompt: str | Sequence[_messages.UserContent] | None = None,
|
|
1039
|
-
*,
|
|
1040
|
-
result_type: type[RunOutputDataT],
|
|
1041
|
-
message_history: list[_messages.ModelMessage] | None = None,
|
|
1042
|
-
model: models.Model | models.KnownModelName | str | None = None,
|
|
1043
|
-
deps: AgentDepsT = None,
|
|
1044
|
-
model_settings: ModelSettings | None = None,
|
|
1045
|
-
usage_limits: _usage.UsageLimits | None = None,
|
|
1046
|
-
usage: _usage.Usage | None = None,
|
|
1047
|
-
infer_name: bool = True,
|
|
1048
|
-
toolsets: Sequence[AbstractToolset[AgentDepsT]] | None = None,
|
|
1049
|
-
) -> AbstractAsyncContextManager[result.StreamedRunResult[AgentDepsT, RunOutputDataT]]: ...
|
|
1050
|
-
|
|
1051
892
|
@asynccontextmanager
|
|
1052
|
-
async def run_stream(
|
|
893
|
+
async def run_stream(
|
|
1053
894
|
self,
|
|
1054
895
|
user_prompt: str | Sequence[_messages.UserContent] | None = None,
|
|
1055
896
|
*,
|
|
@@ -1101,12 +942,6 @@ class Agent(Generic[AgentDepsT, OutputDataT]):
|
|
|
1101
942
|
if frame := inspect.currentframe(): # pragma: no branch
|
|
1102
943
|
self._infer_name(frame.f_back)
|
|
1103
944
|
|
|
1104
|
-
if 'result_type' in _deprecated_kwargs: # pragma: no cover
|
|
1105
|
-
if output_type is not str:
|
|
1106
|
-
raise TypeError('`result_type` and `output_type` cannot be set at the same time.')
|
|
1107
|
-
warnings.warn('`result_type` is deprecated, use `output_type` instead.', DeprecationWarning, stacklevel=2)
|
|
1108
|
-
output_type = _deprecated_kwargs.pop('result_type')
|
|
1109
|
-
|
|
1110
945
|
_utils.validate_empty_kwargs(_deprecated_kwargs)
|
|
1111
946
|
|
|
1112
947
|
yielded = False
|
|
@@ -1431,13 +1266,6 @@ class Agent(Generic[AgentDepsT, OutputDataT]):
|
|
|
1431
1266
|
self._output_validators.append(_output.OutputValidator[AgentDepsT, Any](func))
|
|
1432
1267
|
return func
|
|
1433
1268
|
|
|
1434
|
-
@deprecated('`result_validator` is deprecated, use `output_validator` instead.')
|
|
1435
|
-
def result_validator(self, func: Any, /) -> Any:
|
|
1436
|
-
warnings.warn(
|
|
1437
|
-
'`result_validator` is deprecated, use `output_validator` instead.', DeprecationWarning, stacklevel=2
|
|
1438
|
-
)
|
|
1439
|
-
return self.output_validator(func) # type: ignore
|
|
1440
|
-
|
|
1441
1269
|
@overload
|
|
1442
1270
|
def tool(self, func: ToolFuncContext[AgentDepsT, ToolParams], /) -> ToolFuncContext[AgentDepsT, ToolParams]: ...
|
|
1443
1271
|
|
|
@@ -1718,13 +1546,6 @@ class Agent(Generic[AgentDepsT, OutputDataT]):
|
|
|
1718
1546
|
self.name = name
|
|
1719
1547
|
return
|
|
1720
1548
|
|
|
1721
|
-
@property
|
|
1722
|
-
@deprecated(
|
|
1723
|
-
'The `last_run_messages` attribute has been removed, use `capture_run_messages` instead.', category=None
|
|
1724
|
-
)
|
|
1725
|
-
def last_run_messages(self) -> list[_messages.ModelMessage]:
|
|
1726
|
-
raise AttributeError('The `last_run_messages` attribute has been removed, use `capture_run_messages` instead.')
|
|
1727
|
-
|
|
1728
1549
|
def _prepare_output_schema(
|
|
1729
1550
|
self, output_type: OutputSpec[RunOutputDataT] | None, model_profile: ModelProfile
|
|
1730
1551
|
) -> _output.OutputSchema[RunOutputDataT]:
|
|
@@ -1732,10 +1553,7 @@ class Agent(Generic[AgentDepsT, OutputDataT]):
|
|
|
1732
1553
|
if self._output_validators:
|
|
1733
1554
|
raise exceptions.UserError('Cannot set a custom run `output_type` when the agent has output validators')
|
|
1734
1555
|
schema = _output.OutputSchema[RunOutputDataT].build(
|
|
1735
|
-
output_type,
|
|
1736
|
-
name=self._deprecated_result_tool_name,
|
|
1737
|
-
description=self._deprecated_result_tool_description,
|
|
1738
|
-
default_mode=model_profile.default_structured_output_mode,
|
|
1556
|
+
output_type, default_mode=model_profile.default_structured_output_mode
|
|
1739
1557
|
)
|
|
1740
1558
|
else:
|
|
1741
1559
|
schema = self._output_schema.with_default_mode(model_profile.default_structured_output_mode)
|
|
@@ -2293,11 +2111,6 @@ class AgentRunResult(Generic[OutputDataT]):
|
|
|
2293
2111
|
raise AttributeError('No span was created for this agent run')
|
|
2294
2112
|
return self._traceparent_value
|
|
2295
2113
|
|
|
2296
|
-
@property
|
|
2297
|
-
@deprecated('`result.data` is deprecated, use `result.output` instead.')
|
|
2298
|
-
def data(self) -> OutputDataT:
|
|
2299
|
-
return self.output
|
|
2300
|
-
|
|
2301
2114
|
def _set_output_tool_return(self, return_content: str) -> list[_messages.ModelMessage]:
|
|
2302
2115
|
"""Set return content for the output tool.
|
|
2303
2116
|
|
|
@@ -2319,16 +2132,7 @@ class AgentRunResult(Generic[OutputDataT]):
|
|
|
2319
2132
|
|
|
2320
2133
|
raise LookupError(f'No tool call found with tool name {self._output_tool_name!r}.')
|
|
2321
2134
|
|
|
2322
|
-
|
|
2323
|
-
def all_messages(self, *, output_tool_return_content: str | None = None) -> list[_messages.ModelMessage]: ...
|
|
2324
|
-
|
|
2325
|
-
@overload
|
|
2326
|
-
@deprecated('`result_tool_return_content` is deprecated, use `output_tool_return_content` instead.')
|
|
2327
|
-
def all_messages(self, *, result_tool_return_content: str | None = None) -> list[_messages.ModelMessage]: ...
|
|
2328
|
-
|
|
2329
|
-
def all_messages(
|
|
2330
|
-
self, *, output_tool_return_content: str | None = None, result_tool_return_content: str | None = None
|
|
2331
|
-
) -> list[_messages.ModelMessage]:
|
|
2135
|
+
def all_messages(self, *, output_tool_return_content: str | None = None) -> list[_messages.ModelMessage]:
|
|
2332
2136
|
"""Return the history of _messages.
|
|
2333
2137
|
|
|
2334
2138
|
Args:
|
|
@@ -2336,27 +2140,16 @@ class AgentRunResult(Generic[OutputDataT]):
|
|
|
2336
2140
|
This provides a convenient way to modify the content of the output tool call if you want to continue
|
|
2337
2141
|
the conversation and want to set the response to the output tool call. If `None`, the last message will
|
|
2338
2142
|
not be modified.
|
|
2339
|
-
result_tool_return_content: Deprecated, use `output_tool_return_content` instead.
|
|
2340
2143
|
|
|
2341
2144
|
Returns:
|
|
2342
2145
|
List of messages.
|
|
2343
2146
|
"""
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
return self._set_output_tool_return(content)
|
|
2147
|
+
if output_tool_return_content is not None:
|
|
2148
|
+
return self._set_output_tool_return(output_tool_return_content)
|
|
2347
2149
|
else:
|
|
2348
2150
|
return self._state.message_history
|
|
2349
2151
|
|
|
2350
|
-
|
|
2351
|
-
def all_messages_json(self, *, output_tool_return_content: str | None = None) -> bytes: ...
|
|
2352
|
-
|
|
2353
|
-
@overload
|
|
2354
|
-
@deprecated('`result_tool_return_content` is deprecated, use `output_tool_return_content` instead.')
|
|
2355
|
-
def all_messages_json(self, *, result_tool_return_content: str | None = None) -> bytes: ...
|
|
2356
|
-
|
|
2357
|
-
def all_messages_json(
|
|
2358
|
-
self, *, output_tool_return_content: str | None = None, result_tool_return_content: str | None = None
|
|
2359
|
-
) -> bytes:
|
|
2152
|
+
def all_messages_json(self, *, output_tool_return_content: str | None = None) -> bytes:
|
|
2360
2153
|
"""Return all messages from [`all_messages`][pydantic_ai.agent.AgentRunResult.all_messages] as JSON bytes.
|
|
2361
2154
|
|
|
2362
2155
|
Args:
|
|
@@ -2364,24 +2157,15 @@ class AgentRunResult(Generic[OutputDataT]):
|
|
|
2364
2157
|
This provides a convenient way to modify the content of the output tool call if you want to continue
|
|
2365
2158
|
the conversation and want to set the response to the output tool call. If `None`, the last message will
|
|
2366
2159
|
not be modified.
|
|
2367
|
-
result_tool_return_content: Deprecated, use `output_tool_return_content` instead.
|
|
2368
2160
|
|
|
2369
2161
|
Returns:
|
|
2370
2162
|
JSON bytes representing the messages.
|
|
2371
2163
|
"""
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
@overload
|
|
2376
|
-
def new_messages(self, *, output_tool_return_content: str | None = None) -> list[_messages.ModelMessage]: ...
|
|
2377
|
-
|
|
2378
|
-
@overload
|
|
2379
|
-
@deprecated('`result_tool_return_content` is deprecated, use `output_tool_return_content` instead.')
|
|
2380
|
-
def new_messages(self, *, result_tool_return_content: str | None = None) -> list[_messages.ModelMessage]: ...
|
|
2164
|
+
return _messages.ModelMessagesTypeAdapter.dump_json(
|
|
2165
|
+
self.all_messages(output_tool_return_content=output_tool_return_content)
|
|
2166
|
+
)
|
|
2381
2167
|
|
|
2382
|
-
def new_messages(
|
|
2383
|
-
self, *, output_tool_return_content: str | None = None, result_tool_return_content: str | None = None
|
|
2384
|
-
) -> list[_messages.ModelMessage]:
|
|
2168
|
+
def new_messages(self, *, output_tool_return_content: str | None = None) -> list[_messages.ModelMessage]:
|
|
2385
2169
|
"""Return new messages associated with this run.
|
|
2386
2170
|
|
|
2387
2171
|
Messages from older runs are excluded.
|
|
@@ -2391,24 +2175,13 @@ class AgentRunResult(Generic[OutputDataT]):
|
|
|
2391
2175
|
This provides a convenient way to modify the content of the output tool call if you want to continue
|
|
2392
2176
|
the conversation and want to set the response to the output tool call. If `None`, the last message will
|
|
2393
2177
|
not be modified.
|
|
2394
|
-
result_tool_return_content: Deprecated, use `output_tool_return_content` instead.
|
|
2395
2178
|
|
|
2396
2179
|
Returns:
|
|
2397
2180
|
List of new messages.
|
|
2398
2181
|
"""
|
|
2399
|
-
|
|
2400
|
-
return self.all_messages(output_tool_return_content=content)[self._new_message_index :]
|
|
2401
|
-
|
|
2402
|
-
@overload
|
|
2403
|
-
def new_messages_json(self, *, output_tool_return_content: str | None = None) -> bytes: ...
|
|
2182
|
+
return self.all_messages(output_tool_return_content=output_tool_return_content)[self._new_message_index :]
|
|
2404
2183
|
|
|
2405
|
-
|
|
2406
|
-
@deprecated('`result_tool_return_content` is deprecated, use `output_tool_return_content` instead.')
|
|
2407
|
-
def new_messages_json(self, *, result_tool_return_content: str | None = None) -> bytes: ...
|
|
2408
|
-
|
|
2409
|
-
def new_messages_json(
|
|
2410
|
-
self, *, output_tool_return_content: str | None = None, result_tool_return_content: str | None = None
|
|
2411
|
-
) -> bytes:
|
|
2184
|
+
def new_messages_json(self, *, output_tool_return_content: str | None = None) -> bytes:
|
|
2412
2185
|
"""Return new messages from [`new_messages`][pydantic_ai.agent.AgentRunResult.new_messages] as JSON bytes.
|
|
2413
2186
|
|
|
2414
2187
|
Args:
|
|
@@ -2416,13 +2189,13 @@ class AgentRunResult(Generic[OutputDataT]):
|
|
|
2416
2189
|
This provides a convenient way to modify the content of the output tool call if you want to continue
|
|
2417
2190
|
the conversation and want to set the response to the output tool call. If `None`, the last message will
|
|
2418
2191
|
not be modified.
|
|
2419
|
-
result_tool_return_content: Deprecated, use `output_tool_return_content` instead.
|
|
2420
2192
|
|
|
2421
2193
|
Returns:
|
|
2422
2194
|
JSON bytes representing the new messages.
|
|
2423
2195
|
"""
|
|
2424
|
-
|
|
2425
|
-
|
|
2196
|
+
return _messages.ModelMessagesTypeAdapter.dump_json(
|
|
2197
|
+
self.new_messages(output_tool_return_content=output_tool_return_content)
|
|
2198
|
+
)
|
|
2426
2199
|
|
|
2427
2200
|
def usage(self) -> _usage.Usage:
|
|
2428
2201
|
"""Return the usage of the whole run."""
|
|
@@ -5,9 +5,9 @@ import sys
|
|
|
5
5
|
from typing import TYPE_CHECKING
|
|
6
6
|
|
|
7
7
|
if sys.version_info < (3, 11):
|
|
8
|
-
from exceptiongroup import ExceptionGroup
|
|
8
|
+
from exceptiongroup import ExceptionGroup as ExceptionGroup # pragma: lax no cover
|
|
9
9
|
else:
|
|
10
|
-
ExceptionGroup = ExceptionGroup
|
|
10
|
+
ExceptionGroup = ExceptionGroup # pragma: lax no cover
|
|
11
11
|
|
|
12
12
|
if TYPE_CHECKING:
|
|
13
13
|
from .messages import RetryPromptPart
|
|
@@ -34,8 +34,6 @@ from ..usage import Usage
|
|
|
34
34
|
KnownModelName = TypeAliasType(
|
|
35
35
|
'KnownModelName',
|
|
36
36
|
Literal[
|
|
37
|
-
'anthropic:claude-2.0',
|
|
38
|
-
'anthropic:claude-2.1',
|
|
39
37
|
'anthropic:claude-3-5-haiku-20241022',
|
|
40
38
|
'anthropic:claude-3-5-haiku-latest',
|
|
41
39
|
'anthropic:claude-3-5-sonnet-20240620',
|
|
@@ -46,10 +44,10 @@ KnownModelName = TypeAliasType(
|
|
|
46
44
|
'anthropic:claude-3-haiku-20240307',
|
|
47
45
|
'anthropic:claude-3-opus-20240229',
|
|
48
46
|
'anthropic:claude-3-opus-latest',
|
|
49
|
-
'anthropic:claude-3-sonnet-20240229',
|
|
50
47
|
'anthropic:claude-4-opus-20250514',
|
|
51
48
|
'anthropic:claude-4-sonnet-20250514',
|
|
52
49
|
'anthropic:claude-opus-4-0',
|
|
50
|
+
'anthropic:claude-opus-4-1-20250805',
|
|
53
51
|
'anthropic:claude-opus-4-20250514',
|
|
54
52
|
'anthropic:claude-sonnet-4-0',
|
|
55
53
|
'anthropic:claude-sonnet-4-20250514',
|
|
@@ -100,8 +98,6 @@ KnownModelName = TypeAliasType(
|
|
|
100
98
|
'bedrock:mistral.mixtral-8x7b-instruct-v0:1',
|
|
101
99
|
'bedrock:mistral.mistral-large-2402-v1:0',
|
|
102
100
|
'bedrock:mistral.mistral-large-2407-v1:0',
|
|
103
|
-
'claude-2.0',
|
|
104
|
-
'claude-2.1',
|
|
105
101
|
'claude-3-5-haiku-20241022',
|
|
106
102
|
'claude-3-5-haiku-latest',
|
|
107
103
|
'claude-3-5-sonnet-20240620',
|
|
@@ -112,10 +108,10 @@ KnownModelName = TypeAliasType(
|
|
|
112
108
|
'claude-3-haiku-20240307',
|
|
113
109
|
'claude-3-opus-20240229',
|
|
114
110
|
'claude-3-opus-latest',
|
|
115
|
-
'claude-3-sonnet-20240229',
|
|
116
111
|
'claude-4-opus-20250514',
|
|
117
112
|
'claude-4-sonnet-20250514',
|
|
118
113
|
'claude-opus-4-0',
|
|
114
|
+
'claude-opus-4-1-20250805',
|
|
119
115
|
'claude-opus-4-20250514',
|
|
120
116
|
'claude-sonnet-4-0',
|
|
121
117
|
'claude-sonnet-4-20250514',
|
|
@@ -256,7 +256,7 @@ class AnthropicModel(Model):
|
|
|
256
256
|
except APIStatusError as e:
|
|
257
257
|
if (status_code := e.status_code) >= 400:
|
|
258
258
|
raise ModelHTTPError(status_code=status_code, model_name=self.model_name, body=e.body) from e
|
|
259
|
-
raise # pragma: no cover
|
|
259
|
+
raise # pragma: lax no cover
|
|
260
260
|
|
|
261
261
|
def _process_response(self, response: BetaMessage) -> ModelResponse:
|
|
262
262
|
"""Process a non-streamed response, and prepare a message to return."""
|
|
@@ -183,7 +183,7 @@ class CohereModel(Model):
|
|
|
183
183
|
except ApiError as e:
|
|
184
184
|
if (status_code := e.status_code) and status_code >= 400:
|
|
185
185
|
raise ModelHTTPError(status_code=status_code, model_name=self.model_name, body=e.body) from e
|
|
186
|
-
raise # pragma: no cover
|
|
186
|
+
raise # pragma: lax no cover
|
|
187
187
|
|
|
188
188
|
def _process_response(self, response: V2ChatResponse) -> ModelResponse:
|
|
189
189
|
"""Process a non-streamed response, and prepare a message to return."""
|
|
@@ -11,7 +11,7 @@ from uuid import uuid4
|
|
|
11
11
|
import httpx
|
|
12
12
|
import pydantic
|
|
13
13
|
from httpx import USE_CLIENT_DEFAULT, Response as HTTPResponse
|
|
14
|
-
from typing_extensions import NotRequired, TypedDict, assert_never
|
|
14
|
+
from typing_extensions import NotRequired, TypedDict, assert_never, deprecated
|
|
15
15
|
|
|
16
16
|
from pydantic_ai.providers import Provider, infer_provider
|
|
17
17
|
|
|
@@ -92,6 +92,7 @@ class GeminiModelSettings(ModelSettings, total=False):
|
|
|
92
92
|
"""
|
|
93
93
|
|
|
94
94
|
|
|
95
|
+
@deprecated('Use `GoogleModel` instead. See <https://ai.pydantic.dev/models/google/> for more details.')
|
|
95
96
|
@dataclass(init=False)
|
|
96
97
|
class GeminiModel(Model):
|
|
97
98
|
"""A model that uses Gemini via `generativelanguage.googleapis.com` API.
|
|
@@ -236,7 +237,7 @@ class GeminiModel(Model):
|
|
|
236
237
|
|
|
237
238
|
if gemini_labels := model_settings.get('gemini_labels'):
|
|
238
239
|
if self._system == 'google-vertex':
|
|
239
|
-
request_data['labels'] = gemini_labels
|
|
240
|
+
request_data['labels'] = gemini_labels # pragma: lax no cover
|
|
240
241
|
|
|
241
242
|
headers = {'Content-Type': 'application/json', 'User-Agent': get_user_agent()}
|
|
242
243
|
url = f'/{self._model_name}:{"streamGenerateContent" if streamed else "generateContent"}'
|
|
@@ -366,11 +367,11 @@ class GeminiModel(Model):
|
|
|
366
367
|
inline_data={'data': downloaded_item['data'], 'mime_type': downloaded_item['data_type']}
|
|
367
368
|
)
|
|
368
369
|
content.append(inline_data)
|
|
369
|
-
else:
|
|
370
|
+
else: # pragma: lax no cover
|
|
370
371
|
file_data = _GeminiFileDataPart(file_data={'file_uri': item.url, 'mime_type': item.media_type})
|
|
371
372
|
content.append(file_data)
|
|
372
373
|
else:
|
|
373
|
-
assert_never(item)
|
|
374
|
+
assert_never(item) # pragma: lax no cover
|
|
374
375
|
return content
|
|
375
376
|
|
|
376
377
|
def _map_response_schema(self, o: OutputObjectDefinition) -> dict[str, Any]:
|
|
@@ -407,7 +407,7 @@ class GoogleModel(Model):
|
|
|
407
407
|
content.append(inline_data_dict) # type: ignore
|
|
408
408
|
elif isinstance(item, VideoUrl) and item.is_youtube:
|
|
409
409
|
file_data_dict = {'file_data': {'file_uri': item.url, 'mime_type': item.media_type}}
|
|
410
|
-
if item.vendor_metadata:
|
|
410
|
+
if item.vendor_metadata: # pragma: no branch
|
|
411
411
|
file_data_dict['video_metadata'] = item.vendor_metadata
|
|
412
412
|
content.append(file_data_dict) # type: ignore
|
|
413
413
|
elif isinstance(item, FileUrl):
|
|
@@ -421,7 +421,9 @@ class GoogleModel(Model):
|
|
|
421
421
|
inline_data = {'data': downloaded_item['data'], 'mime_type': downloaded_item['data_type']}
|
|
422
422
|
content.append({'inline_data': inline_data}) # type: ignore
|
|
423
423
|
else:
|
|
424
|
-
content.append(
|
|
424
|
+
content.append(
|
|
425
|
+
{'file_data': {'file_uri': item.url, 'mime_type': item.media_type}}
|
|
426
|
+
) # pragma: lax no cover
|
|
425
427
|
else:
|
|
426
428
|
assert_never(item)
|
|
427
429
|
return content
|
|
@@ -249,7 +249,7 @@ class GroqModel(Model):
|
|
|
249
249
|
except APIStatusError as e:
|
|
250
250
|
if (status_code := e.status_code) >= 400:
|
|
251
251
|
raise ModelHTTPError(status_code=status_code, model_name=self.model_name, body=e.body) from e
|
|
252
|
-
raise # pragma: no cover
|
|
252
|
+
raise # pragma: lax no cover
|
|
253
253
|
|
|
254
254
|
def _process_response(self, response: chat.ChatCompletion) -> ModelResponse:
|
|
255
255
|
"""Process a non-streamed response, and prepare a message to return."""
|