pydantic-ai-slim 1.9.0__tar.gz → 1.10.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-1.9.0 → pydantic_ai_slim-1.10.0}/PKG-INFO +3 -3
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/_run_context.py +6 -2
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/_utils.py +18 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/agent/abstract.py +129 -3
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/durable_exec/temporal/_function_toolset.py +23 -73
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/durable_exec/temporal/_mcp_server.py +30 -30
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/durable_exec/temporal/_run_context.py +7 -2
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/durable_exec/temporal/_toolset.py +67 -3
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/messages.py +6 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/models/google.py +5 -12
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/models/openai.py +4 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/providers/anthropic.py +2 -2
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/providers/openrouter.py +3 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/result.py +154 -1
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/tools.py +10 -6
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/ui/_adapter.py +2 -2
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/ui/_event_stream.py +4 -4
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/ui/ag_ui/_event_stream.py +11 -2
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/ui/ag_ui/app.py +8 -1
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/.gitignore +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/LICENSE +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/README.md +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/__init__.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/__main__.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/_a2a.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/_agent_graph.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/_cli.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/_function_schema.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/_griffe.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/_instrumentation.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/_json_schema.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/_mcp.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/_otel_messages.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/_output.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/_parts_manager.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/_system_prompt.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/_thinking_part.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/_tool_manager.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/ag_ui.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/agent/__init__.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/agent/wrapper.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/builtin_tools.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/common_tools/__init__.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/common_tools/duckduckgo.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/common_tools/tavily.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/direct.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/durable_exec/__init__.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/durable_exec/dbos/__init__.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/durable_exec/dbos/_agent.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/durable_exec/dbos/_mcp_server.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/durable_exec/dbos/_model.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/durable_exec/dbos/_utils.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/durable_exec/prefect/__init__.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/durable_exec/prefect/_agent.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/durable_exec/prefect/_cache_policies.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/durable_exec/prefect/_function_toolset.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/durable_exec/prefect/_mcp_server.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/durable_exec/prefect/_model.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/durable_exec/prefect/_toolset.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/durable_exec/prefect/_types.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/durable_exec/temporal/__init__.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/durable_exec/temporal/_agent.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/durable_exec/temporal/_logfire.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/durable_exec/temporal/_model.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/exceptions.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/ext/__init__.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/ext/aci.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/ext/langchain.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/format_prompt.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/mcp.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/models/__init__.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/models/anthropic.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/models/bedrock.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/models/cohere.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/models/fallback.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/models/function.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/models/gemini.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/models/groq.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/models/huggingface.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/models/instrumented.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/models/mcp_sampling.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/models/mistral.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/models/outlines.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/models/test.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/models/wrapper.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/output.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/profiles/__init__.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/profiles/amazon.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/profiles/anthropic.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/profiles/cohere.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/profiles/deepseek.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/profiles/google.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/profiles/grok.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/profiles/groq.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/profiles/harmony.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/profiles/meta.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/profiles/mistral.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/profiles/moonshotai.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/profiles/openai.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/profiles/qwen.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/providers/__init__.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/providers/azure.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/providers/bedrock.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/providers/cerebras.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/providers/cohere.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/providers/deepseek.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/providers/fireworks.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/providers/gateway.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/providers/github.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/providers/google.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/providers/google_gla.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/providers/google_vertex.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/providers/grok.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/providers/groq.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/providers/heroku.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/providers/huggingface.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/providers/litellm.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/providers/mistral.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/providers/moonshotai.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/providers/nebius.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/providers/ollama.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/providers/openai.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/providers/outlines.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/providers/ovhcloud.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/providers/together.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/providers/vercel.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/py.typed +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/retries.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/run.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/settings.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/toolsets/__init__.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/toolsets/_dynamic.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/toolsets/abstract.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/toolsets/approval_required.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/toolsets/combined.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/toolsets/external.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/toolsets/fastmcp.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/toolsets/filtered.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/toolsets/function.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/toolsets/prefixed.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/toolsets/prepared.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/toolsets/renamed.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/toolsets/wrapper.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/ui/__init__.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/ui/_messages_builder.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/ui/ag_ui/__init__.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/ui/ag_ui/_adapter.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/ui/vercel_ai/__init__.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/ui/vercel_ai/_adapter.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/ui/vercel_ai/_event_stream.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/ui/vercel_ai/_utils.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/ui/vercel_ai/request_types.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/ui/vercel_ai/response_types.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/usage.py +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pyproject.toml +0 -0
- {pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/venv +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pydantic-ai-slim
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.10.0
|
|
4
4
|
Summary: Agent Framework / shim to use Pydantic with LLMs, slim package
|
|
5
5
|
Project-URL: Homepage, https://github.com/pydantic/pydantic-ai/tree/main/pydantic_ai_slim
|
|
6
6
|
Project-URL: Source, https://github.com/pydantic/pydantic-ai/tree/main/pydantic_ai_slim
|
|
@@ -33,7 +33,7 @@ Requires-Dist: genai-prices>=0.0.35
|
|
|
33
33
|
Requires-Dist: griffe>=1.3.2
|
|
34
34
|
Requires-Dist: httpx>=0.27
|
|
35
35
|
Requires-Dist: opentelemetry-api>=1.28.0
|
|
36
|
-
Requires-Dist: pydantic-graph==1.
|
|
36
|
+
Requires-Dist: pydantic-graph==1.10.0
|
|
37
37
|
Requires-Dist: pydantic>=2.10
|
|
38
38
|
Requires-Dist: typing-inspection>=0.4.0
|
|
39
39
|
Provides-Extra: a2a
|
|
@@ -57,7 +57,7 @@ Requires-Dist: dbos>=1.14.0; extra == 'dbos'
|
|
|
57
57
|
Provides-Extra: duckduckgo
|
|
58
58
|
Requires-Dist: ddgs>=9.0.0; extra == 'duckduckgo'
|
|
59
59
|
Provides-Extra: evals
|
|
60
|
-
Requires-Dist: pydantic-evals==1.
|
|
60
|
+
Requires-Dist: pydantic-evals==1.10.0; extra == 'evals'
|
|
61
61
|
Provides-Extra: fastmcp
|
|
62
62
|
Requires-Dist: fastmcp>=2.12.0; extra == 'fastmcp'
|
|
63
63
|
Provides-Extra: google
|
|
@@ -16,15 +16,19 @@ if TYPE_CHECKING:
|
|
|
16
16
|
from .models import Model
|
|
17
17
|
from .result import RunUsage
|
|
18
18
|
|
|
19
|
+
# TODO (v2): Change the default for all typevars like this from `None` to `object`
|
|
19
20
|
AgentDepsT = TypeVar('AgentDepsT', default=None, contravariant=True)
|
|
20
21
|
"""Type variable for agent dependencies."""
|
|
21
22
|
|
|
23
|
+
RunContextAgentDepsT = TypeVar('RunContextAgentDepsT', default=None, covariant=True)
|
|
24
|
+
"""Type variable for the agent dependencies in `RunContext`."""
|
|
25
|
+
|
|
22
26
|
|
|
23
27
|
@dataclasses.dataclass(repr=False, kw_only=True)
|
|
24
|
-
class RunContext(Generic[
|
|
28
|
+
class RunContext(Generic[RunContextAgentDepsT]):
|
|
25
29
|
"""Information about the current call."""
|
|
26
30
|
|
|
27
|
-
deps:
|
|
31
|
+
deps: RunContextAgentDepsT
|
|
28
32
|
"""Dependencies for the agent."""
|
|
29
33
|
model: Model
|
|
30
34
|
"""The model used in this run."""
|
|
@@ -234,6 +234,15 @@ def sync_anext(iterator: Iterator[T]) -> T:
|
|
|
234
234
|
raise StopAsyncIteration() from e
|
|
235
235
|
|
|
236
236
|
|
|
237
|
+
def sync_async_iterator(async_iter: AsyncIterator[T]) -> Iterator[T]:
|
|
238
|
+
loop = get_event_loop()
|
|
239
|
+
while True:
|
|
240
|
+
try:
|
|
241
|
+
yield loop.run_until_complete(anext(async_iter))
|
|
242
|
+
except StopAsyncIteration:
|
|
243
|
+
break
|
|
244
|
+
|
|
245
|
+
|
|
237
246
|
def now_utc() -> datetime:
|
|
238
247
|
return datetime.now(tz=timezone.utc)
|
|
239
248
|
|
|
@@ -489,3 +498,12 @@ def get_union_args(tp: Any) -> tuple[Any, ...]:
|
|
|
489
498
|
return tuple(_unwrap_annotated(arg) for arg in get_args(tp))
|
|
490
499
|
else:
|
|
491
500
|
return ()
|
|
501
|
+
|
|
502
|
+
|
|
503
|
+
def get_event_loop():
|
|
504
|
+
try:
|
|
505
|
+
event_loop = asyncio.get_event_loop()
|
|
506
|
+
except RuntimeError: # pragma: lax no cover
|
|
507
|
+
event_loop = asyncio.new_event_loop()
|
|
508
|
+
asyncio.set_event_loop(event_loop)
|
|
509
|
+
return event_loop
|
|
@@ -12,7 +12,6 @@ import anyio
|
|
|
12
12
|
from typing_extensions import Self, TypeIs, TypeVar
|
|
13
13
|
|
|
14
14
|
from pydantic_graph import End
|
|
15
|
-
from pydantic_graph._utils import get_event_loop
|
|
16
15
|
|
|
17
16
|
from .. import (
|
|
18
17
|
_agent_graph,
|
|
@@ -335,7 +334,7 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
335
334
|
if infer_name and self.name is None:
|
|
336
335
|
self._infer_name(inspect.currentframe())
|
|
337
336
|
|
|
338
|
-
return get_event_loop().run_until_complete(
|
|
337
|
+
return _utils.get_event_loop().run_until_complete(
|
|
339
338
|
self.run(
|
|
340
339
|
user_prompt,
|
|
341
340
|
output_type=output_type,
|
|
@@ -581,6 +580,133 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
581
580
|
if not yielded:
|
|
582
581
|
raise exceptions.AgentRunError('Agent run finished without producing a final result') # pragma: no cover
|
|
583
582
|
|
|
583
|
+
@overload
|
|
584
|
+
def run_stream_sync(
|
|
585
|
+
self,
|
|
586
|
+
user_prompt: str | Sequence[_messages.UserContent] | None = None,
|
|
587
|
+
*,
|
|
588
|
+
output_type: None = None,
|
|
589
|
+
message_history: Sequence[_messages.ModelMessage] | None = None,
|
|
590
|
+
deferred_tool_results: DeferredToolResults | None = None,
|
|
591
|
+
model: models.Model | models.KnownModelName | str | None = None,
|
|
592
|
+
deps: AgentDepsT = None,
|
|
593
|
+
model_settings: ModelSettings | None = None,
|
|
594
|
+
usage_limits: _usage.UsageLimits | None = None,
|
|
595
|
+
usage: _usage.RunUsage | None = None,
|
|
596
|
+
infer_name: bool = True,
|
|
597
|
+
toolsets: Sequence[AbstractToolset[AgentDepsT]] | None = None,
|
|
598
|
+
builtin_tools: Sequence[AbstractBuiltinTool] | None = None,
|
|
599
|
+
event_stream_handler: EventStreamHandler[AgentDepsT] | None = None,
|
|
600
|
+
) -> result.StreamedRunResultSync[AgentDepsT, OutputDataT]: ...
|
|
601
|
+
|
|
602
|
+
@overload
|
|
603
|
+
def run_stream_sync(
|
|
604
|
+
self,
|
|
605
|
+
user_prompt: str | Sequence[_messages.UserContent] | None = None,
|
|
606
|
+
*,
|
|
607
|
+
output_type: OutputSpec[RunOutputDataT],
|
|
608
|
+
message_history: Sequence[_messages.ModelMessage] | None = None,
|
|
609
|
+
deferred_tool_results: DeferredToolResults | 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.RunUsage | None = None,
|
|
615
|
+
infer_name: bool = True,
|
|
616
|
+
toolsets: Sequence[AbstractToolset[AgentDepsT]] | None = None,
|
|
617
|
+
builtin_tools: Sequence[AbstractBuiltinTool] | None = None,
|
|
618
|
+
event_stream_handler: EventStreamHandler[AgentDepsT] | None = None,
|
|
619
|
+
) -> result.StreamedRunResultSync[AgentDepsT, RunOutputDataT]: ...
|
|
620
|
+
|
|
621
|
+
def run_stream_sync(
|
|
622
|
+
self,
|
|
623
|
+
user_prompt: str | Sequence[_messages.UserContent] | None = None,
|
|
624
|
+
*,
|
|
625
|
+
output_type: OutputSpec[RunOutputDataT] | None = None,
|
|
626
|
+
message_history: Sequence[_messages.ModelMessage] | None = None,
|
|
627
|
+
deferred_tool_results: DeferredToolResults | None = None,
|
|
628
|
+
model: models.Model | models.KnownModelName | str | None = None,
|
|
629
|
+
deps: AgentDepsT = None,
|
|
630
|
+
model_settings: ModelSettings | None = None,
|
|
631
|
+
usage_limits: _usage.UsageLimits | None = None,
|
|
632
|
+
usage: _usage.RunUsage | None = None,
|
|
633
|
+
infer_name: bool = True,
|
|
634
|
+
toolsets: Sequence[AbstractToolset[AgentDepsT]] | None = None,
|
|
635
|
+
builtin_tools: Sequence[AbstractBuiltinTool] | None = None,
|
|
636
|
+
event_stream_handler: EventStreamHandler[AgentDepsT] | None = None,
|
|
637
|
+
) -> result.StreamedRunResultSync[AgentDepsT, Any]:
|
|
638
|
+
"""Run the agent with a user prompt in sync streaming mode.
|
|
639
|
+
|
|
640
|
+
This is a convenience method that wraps [`run_stream()`][pydantic_ai.agent.AbstractAgent.run_stream] with `loop.run_until_complete(...)`.
|
|
641
|
+
You therefore can't use this method inside async code or if there's an active event loop.
|
|
642
|
+
|
|
643
|
+
This method builds an internal agent graph (using system prompts, tools and output schemas) and then
|
|
644
|
+
runs the graph until the model produces output matching the `output_type`, for example text or structured data.
|
|
645
|
+
At this point, a streaming run result object is yielded from which you can stream the output as it comes in,
|
|
646
|
+
and -- once this output has completed streaming -- get the complete output, message history, and usage.
|
|
647
|
+
|
|
648
|
+
As this method will consider the first output matching the `output_type` to be the final output,
|
|
649
|
+
it will stop running the agent graph and will not execute any tool calls made by the model after this "final" output.
|
|
650
|
+
If you want to always run the agent graph to completion and stream events and output at the same time,
|
|
651
|
+
use [`agent.run()`][pydantic_ai.agent.AbstractAgent.run] with an `event_stream_handler` or [`agent.iter()`][pydantic_ai.agent.AbstractAgent.iter] instead.
|
|
652
|
+
|
|
653
|
+
Example:
|
|
654
|
+
```python
|
|
655
|
+
from pydantic_ai import Agent
|
|
656
|
+
|
|
657
|
+
agent = Agent('openai:gpt-4o')
|
|
658
|
+
|
|
659
|
+
def main():
|
|
660
|
+
response = agent.run_stream_sync('What is the capital of the UK?')
|
|
661
|
+
print(response.get_output())
|
|
662
|
+
#> The capital of the UK is London.
|
|
663
|
+
```
|
|
664
|
+
|
|
665
|
+
Args:
|
|
666
|
+
user_prompt: User input to start/continue the conversation.
|
|
667
|
+
output_type: Custom output type to use for this run, `output_type` may only be used if the agent has no
|
|
668
|
+
output validators since output validators would expect an argument that matches the agent's output type.
|
|
669
|
+
message_history: History of the conversation so far.
|
|
670
|
+
deferred_tool_results: Optional results for deferred tool calls in the message history.
|
|
671
|
+
model: Optional model to use for this run, required if `model` was not set when creating the agent.
|
|
672
|
+
deps: Optional dependencies to use for this run.
|
|
673
|
+
model_settings: Optional settings to use for this model's request.
|
|
674
|
+
usage_limits: Optional limits on model request count or token usage.
|
|
675
|
+
usage: Optional usage to start with, useful for resuming a conversation or agents used in tools.
|
|
676
|
+
infer_name: Whether to try to infer the agent name from the call frame if it's not set.
|
|
677
|
+
toolsets: Optional additional toolsets for this run.
|
|
678
|
+
builtin_tools: Optional additional builtin tools for this run.
|
|
679
|
+
event_stream_handler: Optional handler for events from the model's streaming response and the agent's execution of tools to use for this run.
|
|
680
|
+
It will receive all the events up until the final result is found, which you can then read or stream from inside the context manager.
|
|
681
|
+
Note that it does _not_ receive any events after the final result is found.
|
|
682
|
+
|
|
683
|
+
Returns:
|
|
684
|
+
The result of the run.
|
|
685
|
+
"""
|
|
686
|
+
if infer_name and self.name is None:
|
|
687
|
+
self._infer_name(inspect.currentframe())
|
|
688
|
+
|
|
689
|
+
async def _consume_stream():
|
|
690
|
+
async with self.run_stream(
|
|
691
|
+
user_prompt,
|
|
692
|
+
output_type=output_type,
|
|
693
|
+
message_history=message_history,
|
|
694
|
+
deferred_tool_results=deferred_tool_results,
|
|
695
|
+
model=model,
|
|
696
|
+
deps=deps,
|
|
697
|
+
model_settings=model_settings,
|
|
698
|
+
usage_limits=usage_limits,
|
|
699
|
+
usage=usage,
|
|
700
|
+
infer_name=infer_name,
|
|
701
|
+
toolsets=toolsets,
|
|
702
|
+
builtin_tools=builtin_tools,
|
|
703
|
+
event_stream_handler=event_stream_handler,
|
|
704
|
+
) as stream_result:
|
|
705
|
+
yield stream_result
|
|
706
|
+
|
|
707
|
+
async_result = _utils.get_event_loop().run_until_complete(anext(_consume_stream()))
|
|
708
|
+
return result.StreamedRunResultSync(async_result)
|
|
709
|
+
|
|
584
710
|
@overload
|
|
585
711
|
def run_stream_events(
|
|
586
712
|
self,
|
|
@@ -1217,6 +1343,6 @@ class AbstractAgent(Generic[AgentDepsT, OutputDataT], ABC):
|
|
|
1217
1343
|
agent.to_cli_sync(prog_name='assistant')
|
|
1218
1344
|
```
|
|
1219
1345
|
"""
|
|
1220
|
-
return get_event_loop().run_until_complete(
|
|
1346
|
+
return _utils.get_event_loop().run_until_complete(
|
|
1221
1347
|
self.to_cli(deps=deps, prog_name=prog_name, message_history=message_history)
|
|
1222
1348
|
)
|
|
@@ -1,57 +1,22 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
from collections.abc import Callable
|
|
4
|
-
from
|
|
5
|
-
from typing import Annotated, Any, Literal
|
|
4
|
+
from typing import Any, Literal
|
|
6
5
|
|
|
7
|
-
from pydantic import ConfigDict, Discriminator, with_config
|
|
8
6
|
from temporalio import activity, workflow
|
|
9
7
|
from temporalio.workflow import ActivityConfig
|
|
10
|
-
from typing_extensions import assert_never
|
|
11
8
|
|
|
12
9
|
from pydantic_ai import FunctionToolset, ToolsetTool
|
|
13
|
-
from pydantic_ai.exceptions import
|
|
10
|
+
from pydantic_ai.exceptions import UserError
|
|
14
11
|
from pydantic_ai.tools import AgentDepsT, RunContext
|
|
15
12
|
from pydantic_ai.toolsets.function import FunctionToolsetTool
|
|
16
13
|
|
|
17
14
|
from ._run_context import TemporalRunContext
|
|
18
|
-
from ._toolset import
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
class _CallToolParams:
|
|
24
|
-
name: str
|
|
25
|
-
tool_args: dict[str, Any]
|
|
26
|
-
serialized_run_context: Any
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
@dataclass
|
|
30
|
-
class _ApprovalRequired:
|
|
31
|
-
kind: Literal['approval_required'] = 'approval_required'
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
@dataclass
|
|
35
|
-
class _CallDeferred:
|
|
36
|
-
kind: Literal['call_deferred'] = 'call_deferred'
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
@dataclass
|
|
40
|
-
class _ModelRetry:
|
|
41
|
-
message: str
|
|
42
|
-
kind: Literal['model_retry'] = 'model_retry'
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
@dataclass
|
|
46
|
-
class _ToolReturn:
|
|
47
|
-
result: Any
|
|
48
|
-
kind: Literal['tool_return'] = 'tool_return'
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
_CallToolResult = Annotated[
|
|
52
|
-
_ApprovalRequired | _CallDeferred | _ModelRetry | _ToolReturn,
|
|
53
|
-
Discriminator('kind'),
|
|
54
|
-
]
|
|
15
|
+
from ._toolset import (
|
|
16
|
+
CallToolParams,
|
|
17
|
+
CallToolResult,
|
|
18
|
+
TemporalWrapperToolset,
|
|
19
|
+
)
|
|
55
20
|
|
|
56
21
|
|
|
57
22
|
class TemporalFunctionToolset(TemporalWrapperToolset[AgentDepsT]):
|
|
@@ -70,7 +35,7 @@ class TemporalFunctionToolset(TemporalWrapperToolset[AgentDepsT]):
|
|
|
70
35
|
self.tool_activity_config = tool_activity_config
|
|
71
36
|
self.run_context_type = run_context_type
|
|
72
37
|
|
|
73
|
-
async def call_tool_activity(params:
|
|
38
|
+
async def call_tool_activity(params: CallToolParams, deps: AgentDepsT) -> CallToolResult:
|
|
74
39
|
name = params.name
|
|
75
40
|
ctx = self.run_context_type.deserialize_run_context(params.serialized_run_context, deps=deps)
|
|
76
41
|
try:
|
|
@@ -84,15 +49,7 @@ class TemporalFunctionToolset(TemporalWrapperToolset[AgentDepsT]):
|
|
|
84
49
|
# The tool args will already have been validated into their proper types in the `ToolManager`,
|
|
85
50
|
# but `execute_activity` would have turned them into simple Python types again, so we need to re-validate them.
|
|
86
51
|
args_dict = tool.args_validator.validate_python(params.tool_args)
|
|
87
|
-
|
|
88
|
-
result = await self.wrapped.call_tool(name, args_dict, ctx, tool)
|
|
89
|
-
return _ToolReturn(result=result)
|
|
90
|
-
except ApprovalRequired:
|
|
91
|
-
return _ApprovalRequired()
|
|
92
|
-
except CallDeferred:
|
|
93
|
-
return _CallDeferred()
|
|
94
|
-
except ModelRetry as e:
|
|
95
|
-
return _ModelRetry(message=e.message)
|
|
52
|
+
return await self._wrap_call_tool_result(self.wrapped.call_tool(name, args_dict, ctx, tool))
|
|
96
53
|
|
|
97
54
|
# Set type hint explicitly so that Temporal can take care of serialization and deserialization
|
|
98
55
|
call_tool_activity.__annotations__['deps'] = deps_type
|
|
@@ -123,25 +80,18 @@ class TemporalFunctionToolset(TemporalWrapperToolset[AgentDepsT]):
|
|
|
123
80
|
|
|
124
81
|
tool_activity_config = self.activity_config | tool_activity_config
|
|
125
82
|
serialized_run_context = self.run_context_type.serialize_run_context(ctx)
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
83
|
+
return self._unwrap_call_tool_result(
|
|
84
|
+
await workflow.execute_activity( # pyright: ignore[reportUnknownMemberType]
|
|
85
|
+
activity=self.call_tool_activity,
|
|
86
|
+
args=[
|
|
87
|
+
CallToolParams(
|
|
88
|
+
name=name,
|
|
89
|
+
tool_args=tool_args,
|
|
90
|
+
serialized_run_context=serialized_run_context,
|
|
91
|
+
tool_def=None,
|
|
92
|
+
),
|
|
93
|
+
ctx.deps,
|
|
94
|
+
],
|
|
95
|
+
**tool_activity_config,
|
|
96
|
+
)
|
|
137
97
|
)
|
|
138
|
-
if isinstance(result, _ApprovalRequired):
|
|
139
|
-
raise ApprovalRequired()
|
|
140
|
-
elif isinstance(result, _CallDeferred):
|
|
141
|
-
raise CallDeferred()
|
|
142
|
-
elif isinstance(result, _ModelRetry):
|
|
143
|
-
raise ModelRetry(result.message)
|
|
144
|
-
elif isinstance(result, _ToolReturn):
|
|
145
|
-
return result.result
|
|
146
|
-
else:
|
|
147
|
-
assert_never(result)
|
{pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/durable_exec/temporal/_mcp_server.py
RENAMED
|
@@ -11,11 +11,15 @@ from typing_extensions import Self
|
|
|
11
11
|
|
|
12
12
|
from pydantic_ai import ToolsetTool
|
|
13
13
|
from pydantic_ai.exceptions import UserError
|
|
14
|
-
from pydantic_ai.mcp import MCPServer
|
|
14
|
+
from pydantic_ai.mcp import MCPServer
|
|
15
15
|
from pydantic_ai.tools import AgentDepsT, RunContext, ToolDefinition
|
|
16
16
|
|
|
17
17
|
from ._run_context import TemporalRunContext
|
|
18
|
-
from ._toolset import
|
|
18
|
+
from ._toolset import (
|
|
19
|
+
CallToolParams,
|
|
20
|
+
CallToolResult,
|
|
21
|
+
TemporalWrapperToolset,
|
|
22
|
+
)
|
|
19
23
|
|
|
20
24
|
|
|
21
25
|
@dataclass
|
|
@@ -24,15 +28,6 @@ class _GetToolsParams:
|
|
|
24
28
|
serialized_run_context: Any
|
|
25
29
|
|
|
26
30
|
|
|
27
|
-
@dataclass
|
|
28
|
-
@with_config(ConfigDict(arbitrary_types_allowed=True))
|
|
29
|
-
class _CallToolParams:
|
|
30
|
-
name: str
|
|
31
|
-
tool_args: dict[str, Any]
|
|
32
|
-
serialized_run_context: Any
|
|
33
|
-
tool_def: ToolDefinition
|
|
34
|
-
|
|
35
|
-
|
|
36
31
|
class TemporalMCPServer(TemporalWrapperToolset[AgentDepsT]):
|
|
37
32
|
def __init__(
|
|
38
33
|
self,
|
|
@@ -72,13 +67,16 @@ class TemporalMCPServer(TemporalWrapperToolset[AgentDepsT]):
|
|
|
72
67
|
get_tools_activity
|
|
73
68
|
)
|
|
74
69
|
|
|
75
|
-
async def call_tool_activity(params:
|
|
70
|
+
async def call_tool_activity(params: CallToolParams, deps: AgentDepsT) -> CallToolResult:
|
|
76
71
|
run_context = self.run_context_type.deserialize_run_context(params.serialized_run_context, deps=deps)
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
72
|
+
assert isinstance(params.tool_def, ToolDefinition)
|
|
73
|
+
return await self._wrap_call_tool_result(
|
|
74
|
+
self.wrapped.call_tool(
|
|
75
|
+
params.name,
|
|
76
|
+
params.tool_args,
|
|
77
|
+
run_context,
|
|
78
|
+
self.tool_for_tool_def(params.tool_def),
|
|
79
|
+
)
|
|
82
80
|
)
|
|
83
81
|
|
|
84
82
|
# Set type hint explicitly so that Temporal can take care of serialization and deserialization
|
|
@@ -125,22 +123,24 @@ class TemporalMCPServer(TemporalWrapperToolset[AgentDepsT]):
|
|
|
125
123
|
tool_args: dict[str, Any],
|
|
126
124
|
ctx: RunContext[AgentDepsT],
|
|
127
125
|
tool: ToolsetTool[AgentDepsT],
|
|
128
|
-
) ->
|
|
126
|
+
) -> CallToolResult:
|
|
129
127
|
if not workflow.in_workflow():
|
|
130
128
|
return await super().call_tool(name, tool_args, ctx, tool)
|
|
131
129
|
|
|
132
130
|
tool_activity_config = self.activity_config | self.tool_activity_config.get(name, {})
|
|
133
131
|
serialized_run_context = self.run_context_type.serialize_run_context(ctx)
|
|
134
|
-
return
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
132
|
+
return self._unwrap_call_tool_result(
|
|
133
|
+
await workflow.execute_activity( # pyright: ignore[reportUnknownMemberType]
|
|
134
|
+
activity=self.call_tool_activity,
|
|
135
|
+
args=[
|
|
136
|
+
CallToolParams(
|
|
137
|
+
name=name,
|
|
138
|
+
tool_args=tool_args,
|
|
139
|
+
serialized_run_context=serialized_run_context,
|
|
140
|
+
tool_def=tool.tool_def,
|
|
141
|
+
),
|
|
142
|
+
ctx.deps,
|
|
143
|
+
],
|
|
144
|
+
**tool_activity_config,
|
|
145
|
+
)
|
|
146
146
|
)
|
{pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/durable_exec/temporal/_run_context.py
RENAMED
|
@@ -2,8 +2,13 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from typing import Any
|
|
4
4
|
|
|
5
|
+
from typing_extensions import TypeVar
|
|
6
|
+
|
|
5
7
|
from pydantic_ai.exceptions import UserError
|
|
6
|
-
from pydantic_ai.tools import
|
|
8
|
+
from pydantic_ai.tools import RunContext
|
|
9
|
+
|
|
10
|
+
AgentDepsT = TypeVar('AgentDepsT', default=None, covariant=True)
|
|
11
|
+
"""Type variable for the agent dependencies in `RunContext`."""
|
|
7
12
|
|
|
8
13
|
|
|
9
14
|
class TemporalRunContext(RunContext[AgentDepsT]):
|
|
@@ -47,6 +52,6 @@ class TemporalRunContext(RunContext[AgentDepsT]):
|
|
|
47
52
|
}
|
|
48
53
|
|
|
49
54
|
@classmethod
|
|
50
|
-
def deserialize_run_context(cls, ctx: dict[str, Any], deps:
|
|
55
|
+
def deserialize_run_context(cls, ctx: dict[str, Any], deps: Any) -> TemporalRunContext[Any]:
|
|
51
56
|
"""Deserialize the run context from a `dict[str, Any]`."""
|
|
52
57
|
return cls(**ctx, deps=deps)
|
{pydantic_ai_slim-1.9.0 → pydantic_ai_slim-1.10.0}/pydantic_ai/durable_exec/temporal/_toolset.py
RENAMED
|
@@ -1,17 +1,58 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
from abc import ABC, abstractmethod
|
|
4
|
-
from collections.abc import Callable
|
|
5
|
-
from
|
|
4
|
+
from collections.abc import Awaitable, Callable
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
from typing import Annotated, Any, Literal
|
|
6
7
|
|
|
8
|
+
from pydantic import ConfigDict, Discriminator, with_config
|
|
7
9
|
from temporalio.workflow import ActivityConfig
|
|
10
|
+
from typing_extensions import assert_never
|
|
8
11
|
|
|
9
12
|
from pydantic_ai import AbstractToolset, FunctionToolset, WrapperToolset
|
|
10
|
-
from pydantic_ai.
|
|
13
|
+
from pydantic_ai.exceptions import ApprovalRequired, CallDeferred, ModelRetry
|
|
14
|
+
from pydantic_ai.tools import AgentDepsT, ToolDefinition
|
|
11
15
|
|
|
12
16
|
from ._run_context import TemporalRunContext
|
|
13
17
|
|
|
14
18
|
|
|
19
|
+
@dataclass
|
|
20
|
+
@with_config(ConfigDict(arbitrary_types_allowed=True))
|
|
21
|
+
class CallToolParams:
|
|
22
|
+
name: str
|
|
23
|
+
tool_args: dict[str, Any]
|
|
24
|
+
serialized_run_context: Any
|
|
25
|
+
tool_def: ToolDefinition | None
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@dataclass
|
|
29
|
+
class _ApprovalRequired:
|
|
30
|
+
kind: Literal['approval_required'] = 'approval_required'
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@dataclass
|
|
34
|
+
class _CallDeferred:
|
|
35
|
+
kind: Literal['call_deferred'] = 'call_deferred'
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
@dataclass
|
|
39
|
+
class _ModelRetry:
|
|
40
|
+
message: str
|
|
41
|
+
kind: Literal['model_retry'] = 'model_retry'
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
@dataclass
|
|
45
|
+
class _ToolReturn:
|
|
46
|
+
result: Any
|
|
47
|
+
kind: Literal['tool_return'] = 'tool_return'
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
CallToolResult = Annotated[
|
|
51
|
+
_ApprovalRequired | _CallDeferred | _ModelRetry | _ToolReturn,
|
|
52
|
+
Discriminator('kind'),
|
|
53
|
+
]
|
|
54
|
+
|
|
55
|
+
|
|
15
56
|
class TemporalWrapperToolset(WrapperToolset[AgentDepsT], ABC):
|
|
16
57
|
@property
|
|
17
58
|
def id(self) -> str:
|
|
@@ -30,6 +71,29 @@ class TemporalWrapperToolset(WrapperToolset[AgentDepsT], ABC):
|
|
|
30
71
|
# Temporalized toolsets cannot be swapped out after the fact.
|
|
31
72
|
return self
|
|
32
73
|
|
|
74
|
+
async def _wrap_call_tool_result(self, coro: Awaitable[Any]) -> CallToolResult:
|
|
75
|
+
try:
|
|
76
|
+
result = await coro
|
|
77
|
+
return _ToolReturn(result=result)
|
|
78
|
+
except ApprovalRequired:
|
|
79
|
+
return _ApprovalRequired()
|
|
80
|
+
except CallDeferred:
|
|
81
|
+
return _CallDeferred()
|
|
82
|
+
except ModelRetry as e:
|
|
83
|
+
return _ModelRetry(message=e.message)
|
|
84
|
+
|
|
85
|
+
def _unwrap_call_tool_result(self, result: CallToolResult) -> Any:
|
|
86
|
+
if isinstance(result, _ToolReturn):
|
|
87
|
+
return result.result
|
|
88
|
+
elif isinstance(result, _ApprovalRequired):
|
|
89
|
+
raise ApprovalRequired()
|
|
90
|
+
elif isinstance(result, _CallDeferred):
|
|
91
|
+
raise CallDeferred()
|
|
92
|
+
elif isinstance(result, _ModelRetry):
|
|
93
|
+
raise ModelRetry(result.message)
|
|
94
|
+
else:
|
|
95
|
+
assert_never(result)
|
|
96
|
+
|
|
33
97
|
|
|
34
98
|
def temporalize_toolset(
|
|
35
99
|
toolset: AbstractToolset[AgentDepsT],
|
|
@@ -34,6 +34,7 @@ DocumentMediaType: TypeAlias = Literal[
|
|
|
34
34
|
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
35
35
|
'text/html',
|
|
36
36
|
'text/markdown',
|
|
37
|
+
'application/msword',
|
|
37
38
|
'application/vnd.ms-excel',
|
|
38
39
|
]
|
|
39
40
|
VideoMediaType: TypeAlias = Literal[
|
|
@@ -434,8 +435,12 @@ class DocumentUrl(FileUrl):
|
|
|
434
435
|
return 'application/pdf'
|
|
435
436
|
elif self.url.endswith('.rtf'):
|
|
436
437
|
return 'application/rtf'
|
|
438
|
+
elif self.url.endswith('.doc'):
|
|
439
|
+
return 'application/msword'
|
|
437
440
|
elif self.url.endswith('.docx'):
|
|
438
441
|
return 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
|
|
442
|
+
elif self.url.endswith('.xls'):
|
|
443
|
+
return 'application/vnd.ms-excel'
|
|
439
444
|
elif self.url.endswith('.xlsx'):
|
|
440
445
|
return 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
|
441
446
|
|
|
@@ -645,6 +650,7 @@ _document_format_lookup: dict[str, DocumentFormat] = {
|
|
|
645
650
|
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': 'xlsx',
|
|
646
651
|
'text/html': 'html',
|
|
647
652
|
'text/markdown': 'md',
|
|
653
|
+
'application/msword': 'doc',
|
|
648
654
|
'application/vnd.ms-excel': 'xls',
|
|
649
655
|
}
|
|
650
656
|
_audio_format_lookup: dict[str, AudioFormat] = {
|
|
@@ -471,11 +471,9 @@ class GoogleModel(Model):
|
|
|
471
471
|
raise UnexpectedModelBehavior(
|
|
472
472
|
f'Content filter {raw_finish_reason.value!r} triggered', response.model_dump_json()
|
|
473
473
|
)
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
) # pragma: no cover
|
|
478
|
-
parts = candidate.content.parts or []
|
|
474
|
+
parts = [] # pragma: no cover
|
|
475
|
+
else:
|
|
476
|
+
parts = candidate.content.parts or []
|
|
479
477
|
|
|
480
478
|
usage = _metadata_as_usage(response)
|
|
481
479
|
return _process_response_from_parts(
|
|
@@ -649,17 +647,12 @@ class GeminiStreamedResponse(StreamedResponse):
|
|
|
649
647
|
# )
|
|
650
648
|
|
|
651
649
|
if candidate.content is None or candidate.content.parts is None:
|
|
652
|
-
if self.finish_reason == '
|
|
653
|
-
# Normal completion - skip this chunk
|
|
654
|
-
continue
|
|
655
|
-
elif self.finish_reason == 'content_filter' and raw_finish_reason: # pragma: no cover
|
|
650
|
+
if self.finish_reason == 'content_filter' and raw_finish_reason: # pragma: no cover
|
|
656
651
|
raise UnexpectedModelBehavior(
|
|
657
652
|
f'Content filter {raw_finish_reason.value!r} triggered', chunk.model_dump_json()
|
|
658
653
|
)
|
|
659
654
|
else: # pragma: no cover
|
|
660
|
-
|
|
661
|
-
'Content field missing from streaming Gemini response', chunk.model_dump_json()
|
|
662
|
-
)
|
|
655
|
+
continue
|
|
663
656
|
|
|
664
657
|
parts = candidate.content.parts
|
|
665
658
|
if not parts:
|
|
@@ -948,6 +948,10 @@ class OpenAIResponsesModel(Model):
|
|
|
948
948
|
|
|
949
949
|
super().__init__(settings=settings, profile=profile or provider.model_profile)
|
|
950
950
|
|
|
951
|
+
@property
|
|
952
|
+
def base_url(self) -> str:
|
|
953
|
+
return str(self.client.base_url)
|
|
954
|
+
|
|
951
955
|
@property
|
|
952
956
|
def model_name(self) -> OpenAIModelName:
|
|
953
957
|
"""The model name."""
|
|
@@ -12,7 +12,7 @@ from pydantic_ai.profiles.anthropic import anthropic_model_profile
|
|
|
12
12
|
from pydantic_ai.providers import Provider
|
|
13
13
|
|
|
14
14
|
try:
|
|
15
|
-
from anthropic import AsyncAnthropic, AsyncAnthropicBedrock
|
|
15
|
+
from anthropic import AsyncAnthropic, AsyncAnthropicBedrock, AsyncAnthropicVertex
|
|
16
16
|
except ImportError as _import_error:
|
|
17
17
|
raise ImportError(
|
|
18
18
|
'Please install the `anthropic` package to use the Anthropic provider, '
|
|
@@ -20,7 +20,7 @@ except ImportError as _import_error:
|
|
|
20
20
|
) from _import_error
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
AsyncAnthropicClient: TypeAlias = AsyncAnthropic | AsyncAnthropicBedrock
|
|
23
|
+
AsyncAnthropicClient: TypeAlias = AsyncAnthropic | AsyncAnthropicBedrock | AsyncAnthropicVertex
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
class AnthropicProvider(Provider[AsyncAnthropicClient]):
|