pydantic-ai-slim 1.0.17__tar.gz → 1.1.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.0.17 → pydantic_ai_slim-1.1.0}/PKG-INFO +5 -3
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/_parts_manager.py +3 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/agent/__init__.py +43 -12
- pydantic_ai_slim-1.1.0/pydantic_ai/durable_exec/prefect/__init__.py +15 -0
- pydantic_ai_slim-1.1.0/pydantic_ai/durable_exec/prefect/_agent.py +833 -0
- pydantic_ai_slim-1.1.0/pydantic_ai/durable_exec/prefect/_cache_policies.py +102 -0
- pydantic_ai_slim-1.1.0/pydantic_ai/durable_exec/prefect/_function_toolset.py +58 -0
- pydantic_ai_slim-1.1.0/pydantic_ai/durable_exec/prefect/_mcp_server.py +60 -0
- pydantic_ai_slim-1.1.0/pydantic_ai/durable_exec/prefect/_model.py +152 -0
- pydantic_ai_slim-1.1.0/pydantic_ai/durable_exec/prefect/_toolset.py +67 -0
- pydantic_ai_slim-1.1.0/pydantic_ai/durable_exec/prefect/_types.py +44 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/durable_exec/temporal/__init__.py +2 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/messages.py +7 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/models/__init__.py +2 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/models/google.py +6 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/models/openai.py +17 -10
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/providers/__init__.py +4 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/providers/gateway.py +16 -7
- pydantic_ai_slim-1.1.0/pydantic_ai/providers/nebius.py +102 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/toolsets/function.py +19 -12
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pyproject.toml +2 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/.gitignore +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/LICENSE +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/README.md +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/__init__.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/__main__.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/_a2a.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/_agent_graph.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/_cli.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/_function_schema.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/_griffe.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/_instrumentation.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/_json_schema.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/_mcp.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/_otel_messages.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/_output.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/_run_context.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/_system_prompt.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/_thinking_part.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/_tool_manager.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/_utils.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/ag_ui.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/agent/abstract.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/agent/wrapper.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/builtin_tools.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/common_tools/__init__.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/common_tools/duckduckgo.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/common_tools/tavily.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/direct.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/durable_exec/__init__.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/durable_exec/dbos/__init__.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/durable_exec/dbos/_agent.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/durable_exec/dbos/_mcp_server.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/durable_exec/dbos/_model.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/durable_exec/dbos/_utils.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/durable_exec/temporal/_agent.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/durable_exec/temporal/_function_toolset.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/durable_exec/temporal/_logfire.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/durable_exec/temporal/_mcp_server.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/durable_exec/temporal/_model.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/durable_exec/temporal/_run_context.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/durable_exec/temporal/_toolset.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/exceptions.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/ext/__init__.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/ext/aci.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/ext/langchain.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/format_prompt.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/mcp.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/models/anthropic.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/models/bedrock.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/models/cohere.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/models/fallback.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/models/function.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/models/gemini.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/models/groq.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/models/huggingface.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/models/instrumented.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/models/mcp_sampling.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/models/mistral.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/models/test.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/models/wrapper.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/output.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/profiles/__init__.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/profiles/amazon.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/profiles/anthropic.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/profiles/cohere.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/profiles/deepseek.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/profiles/google.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/profiles/grok.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/profiles/groq.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/profiles/harmony.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/profiles/meta.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/profiles/mistral.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/profiles/moonshotai.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/profiles/openai.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/profiles/qwen.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/providers/anthropic.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/providers/azure.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/providers/bedrock.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/providers/cerebras.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/providers/cohere.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/providers/deepseek.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/providers/fireworks.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/providers/github.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/providers/google.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/providers/google_gla.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/providers/google_vertex.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/providers/grok.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/providers/groq.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/providers/heroku.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/providers/huggingface.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/providers/litellm.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/providers/mistral.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/providers/moonshotai.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/providers/ollama.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/providers/openai.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/providers/openrouter.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/providers/together.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/providers/vercel.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/py.typed +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/result.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/retries.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/run.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/settings.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/tools.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/toolsets/__init__.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/toolsets/_dynamic.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/toolsets/abstract.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/toolsets/approval_required.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/toolsets/combined.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/toolsets/external.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/toolsets/filtered.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/toolsets/prefixed.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/toolsets/prepared.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/toolsets/renamed.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.0}/pydantic_ai/toolsets/wrapper.py +0 -0
- {pydantic_ai_slim-1.0.17 → pydantic_ai_slim-1.1.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: 1.0
|
|
3
|
+
Version: 1.1.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.30
|
|
|
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.0
|
|
36
|
+
Requires-Dist: pydantic-graph==1.1.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.0
|
|
60
|
+
Requires-Dist: pydantic-evals==1.1.0; extra == 'evals'
|
|
61
61
|
Provides-Extra: google
|
|
62
62
|
Requires-Dist: google-genai>=1.31.0; extra == 'google'
|
|
63
63
|
Provides-Extra: groq
|
|
@@ -72,6 +72,8 @@ Provides-Extra: mistral
|
|
|
72
72
|
Requires-Dist: mistralai>=1.9.10; extra == 'mistral'
|
|
73
73
|
Provides-Extra: openai
|
|
74
74
|
Requires-Dist: openai>=1.107.2; extra == 'openai'
|
|
75
|
+
Provides-Extra: prefect
|
|
76
|
+
Requires-Dist: prefect>=3.4.21; extra == 'prefect'
|
|
75
77
|
Provides-Extra: retries
|
|
76
78
|
Requires-Dist: tenacity>=8.2.3; extra == 'retries'
|
|
77
79
|
Provides-Extra: tavily
|
|
@@ -312,6 +312,7 @@ class ModelResponsePartsManager:
|
|
|
312
312
|
tool_name: str,
|
|
313
313
|
args: str | dict[str, Any] | None,
|
|
314
314
|
tool_call_id: str | None = None,
|
|
315
|
+
id: str | None = None,
|
|
315
316
|
) -> ModelResponseStreamEvent:
|
|
316
317
|
"""Immediately create or fully-overwrite a ToolCallPart with the given information.
|
|
317
318
|
|
|
@@ -323,6 +324,7 @@ class ModelResponsePartsManager:
|
|
|
323
324
|
tool_name: The name of the tool being invoked.
|
|
324
325
|
args: The arguments for the tool call, either as a string, a dictionary, or None.
|
|
325
326
|
tool_call_id: An optional string identifier for this tool call.
|
|
327
|
+
id: An optional identifier for this tool call part.
|
|
326
328
|
|
|
327
329
|
Returns:
|
|
328
330
|
ModelResponseStreamEvent: A `PartStartEvent` indicating that a new tool call part
|
|
@@ -332,6 +334,7 @@ class ModelResponsePartsManager:
|
|
|
332
334
|
tool_name=tool_name,
|
|
333
335
|
args=args,
|
|
334
336
|
tool_call_id=tool_call_id or _generate_tool_call_id(),
|
|
337
|
+
id=id,
|
|
335
338
|
)
|
|
336
339
|
if vendor_part_id is None:
|
|
337
340
|
# vendor_part_id is None, so we unconditionally append a new ToolCallPart to the end of the list
|
|
@@ -685,30 +685,53 @@ class Agent(AbstractAgent[AgentDepsT, OutputDataT]):
|
|
|
685
685
|
finally:
|
|
686
686
|
try:
|
|
687
687
|
if instrumentation_settings and run_span.is_recording():
|
|
688
|
-
run_span.set_attributes(
|
|
688
|
+
run_span.set_attributes(
|
|
689
|
+
self._run_span_end_attributes(
|
|
690
|
+
instrumentation_settings, usage, state.message_history, graph_deps.new_message_index
|
|
691
|
+
)
|
|
692
|
+
)
|
|
689
693
|
finally:
|
|
690
694
|
run_span.end()
|
|
691
695
|
|
|
692
696
|
def _run_span_end_attributes(
|
|
693
|
-
self,
|
|
697
|
+
self,
|
|
698
|
+
settings: InstrumentationSettings,
|
|
699
|
+
usage: _usage.RunUsage,
|
|
700
|
+
message_history: list[_messages.ModelMessage],
|
|
701
|
+
new_message_index: int,
|
|
694
702
|
):
|
|
695
|
-
literal_instructions, _ = self._get_instructions()
|
|
696
|
-
|
|
697
703
|
if settings.version == 1:
|
|
698
704
|
attrs = {
|
|
699
705
|
'all_messages_events': json.dumps(
|
|
700
|
-
[
|
|
701
|
-
InstrumentedModel.event_to_dict(e)
|
|
702
|
-
for e in settings.messages_to_otel_events(state.message_history)
|
|
703
|
-
]
|
|
706
|
+
[InstrumentedModel.event_to_dict(e) for e in settings.messages_to_otel_events(message_history)]
|
|
704
707
|
)
|
|
705
708
|
}
|
|
706
709
|
else:
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
+
# Store the last instructions here for convenience
|
|
711
|
+
last_instructions = InstrumentedModel._get_instructions(message_history) # pyright: ignore[reportPrivateUsage]
|
|
712
|
+
attrs: dict[str, Any] = {
|
|
713
|
+
'pydantic_ai.all_messages': json.dumps(settings.messages_to_otel_messages(list(message_history))),
|
|
714
|
+
**settings.system_instructions_attributes(last_instructions),
|
|
710
715
|
}
|
|
711
716
|
|
|
717
|
+
# If this agent run was provided with existing history, store an attribute indicating the point at which the
|
|
718
|
+
# new messages begin.
|
|
719
|
+
if new_message_index > 0:
|
|
720
|
+
attrs['pydantic_ai.new_message_index'] = new_message_index
|
|
721
|
+
|
|
722
|
+
# If the instructions for this agent run were not always the same, store an attribute that indicates that.
|
|
723
|
+
# This can signal to an observability UI that different steps in the agent run had different instructions.
|
|
724
|
+
# Note: We purposely only look at "new" messages because they are the only ones produced by this agent run.
|
|
725
|
+
if any(
|
|
726
|
+
(
|
|
727
|
+
isinstance(m, _messages.ModelRequest)
|
|
728
|
+
and m.instructions is not None
|
|
729
|
+
and m.instructions != last_instructions
|
|
730
|
+
)
|
|
731
|
+
for m in message_history[new_message_index:]
|
|
732
|
+
):
|
|
733
|
+
attrs['pydantic_ai.variable_instructions'] = True
|
|
734
|
+
|
|
712
735
|
return {
|
|
713
736
|
**usage.opentelemetry_attributes(),
|
|
714
737
|
**attrs,
|
|
@@ -716,7 +739,7 @@ class Agent(AbstractAgent[AgentDepsT, OutputDataT]):
|
|
|
716
739
|
{
|
|
717
740
|
'type': 'object',
|
|
718
741
|
'properties': {
|
|
719
|
-
**{
|
|
742
|
+
**{k: {'type': 'array'} if isinstance(v, str) else {} for k, v in attrs.items()},
|
|
720
743
|
'final_result': {'type': 'object'},
|
|
721
744
|
},
|
|
722
745
|
}
|
|
@@ -1006,6 +1029,7 @@ class Agent(AbstractAgent[AgentDepsT, OutputDataT]):
|
|
|
1006
1029
|
/,
|
|
1007
1030
|
*,
|
|
1008
1031
|
name: str | None = None,
|
|
1032
|
+
description: str | None = None,
|
|
1009
1033
|
retries: int | None = None,
|
|
1010
1034
|
prepare: ToolPrepareFunc[AgentDepsT] | None = None,
|
|
1011
1035
|
docstring_format: DocstringFormat = 'auto',
|
|
@@ -1023,6 +1047,7 @@ class Agent(AbstractAgent[AgentDepsT, OutputDataT]):
|
|
|
1023
1047
|
/,
|
|
1024
1048
|
*,
|
|
1025
1049
|
name: str | None = None,
|
|
1050
|
+
description: str | None = None,
|
|
1026
1051
|
retries: int | None = None,
|
|
1027
1052
|
prepare: ToolPrepareFunc[AgentDepsT] | None = None,
|
|
1028
1053
|
docstring_format: DocstringFormat = 'auto',
|
|
@@ -1065,6 +1090,7 @@ class Agent(AbstractAgent[AgentDepsT, OutputDataT]):
|
|
|
1065
1090
|
Args:
|
|
1066
1091
|
func: The tool function to register.
|
|
1067
1092
|
name: The name of the tool, defaults to the function name.
|
|
1093
|
+
description: The description of the tool, defaults to the function docstring.
|
|
1068
1094
|
retries: The number of retries to allow for this tool, defaults to the agent's default retries,
|
|
1069
1095
|
which defaults to 1.
|
|
1070
1096
|
prepare: custom method to prepare the tool definition for each step, return `None` to omit this
|
|
@@ -1090,6 +1116,7 @@ class Agent(AbstractAgent[AgentDepsT, OutputDataT]):
|
|
|
1090
1116
|
func_,
|
|
1091
1117
|
takes_ctx=True,
|
|
1092
1118
|
name=name,
|
|
1119
|
+
description=description,
|
|
1093
1120
|
retries=retries,
|
|
1094
1121
|
prepare=prepare,
|
|
1095
1122
|
docstring_format=docstring_format,
|
|
@@ -1113,6 +1140,7 @@ class Agent(AbstractAgent[AgentDepsT, OutputDataT]):
|
|
|
1113
1140
|
/,
|
|
1114
1141
|
*,
|
|
1115
1142
|
name: str | None = None,
|
|
1143
|
+
description: str | None = None,
|
|
1116
1144
|
retries: int | None = None,
|
|
1117
1145
|
prepare: ToolPrepareFunc[AgentDepsT] | None = None,
|
|
1118
1146
|
docstring_format: DocstringFormat = 'auto',
|
|
@@ -1130,6 +1158,7 @@ class Agent(AbstractAgent[AgentDepsT, OutputDataT]):
|
|
|
1130
1158
|
/,
|
|
1131
1159
|
*,
|
|
1132
1160
|
name: str | None = None,
|
|
1161
|
+
description: str | None = None,
|
|
1133
1162
|
retries: int | None = None,
|
|
1134
1163
|
prepare: ToolPrepareFunc[AgentDepsT] | None = None,
|
|
1135
1164
|
docstring_format: DocstringFormat = 'auto',
|
|
@@ -1172,6 +1201,7 @@ class Agent(AbstractAgent[AgentDepsT, OutputDataT]):
|
|
|
1172
1201
|
Args:
|
|
1173
1202
|
func: The tool function to register.
|
|
1174
1203
|
name: The name of the tool, defaults to the function name.
|
|
1204
|
+
description: The description of the tool, defaults to the function docstring.
|
|
1175
1205
|
retries: The number of retries to allow for this tool, defaults to the agent's default retries,
|
|
1176
1206
|
which defaults to 1.
|
|
1177
1207
|
prepare: custom method to prepare the tool definition for each step, return `None` to omit this
|
|
@@ -1195,6 +1225,7 @@ class Agent(AbstractAgent[AgentDepsT, OutputDataT]):
|
|
|
1195
1225
|
func_,
|
|
1196
1226
|
takes_ctx=False,
|
|
1197
1227
|
name=name,
|
|
1228
|
+
description=description,
|
|
1198
1229
|
retries=retries,
|
|
1199
1230
|
prepare=prepare,
|
|
1200
1231
|
docstring_format=docstring_format,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from ._agent import PrefectAgent
|
|
2
|
+
from ._cache_policies import DEFAULT_PYDANTIC_AI_CACHE_POLICY
|
|
3
|
+
from ._function_toolset import PrefectFunctionToolset
|
|
4
|
+
from ._mcp_server import PrefectMCPServer
|
|
5
|
+
from ._model import PrefectModel
|
|
6
|
+
from ._types import TaskConfig
|
|
7
|
+
|
|
8
|
+
__all__ = [
|
|
9
|
+
'PrefectAgent',
|
|
10
|
+
'PrefectModel',
|
|
11
|
+
'PrefectMCPServer',
|
|
12
|
+
'PrefectFunctionToolset',
|
|
13
|
+
'TaskConfig',
|
|
14
|
+
'DEFAULT_PYDANTIC_AI_CACHE_POLICY',
|
|
15
|
+
]
|