pydantic-ai 1.0.0b1__py3-none-any.whl → 1.0.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pydantic-ai might be problematic. Click here for more details.

README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  </a>
8
8
  </div>
9
9
  <div align="center">
10
- <em>Agent Framework / shim to use Pydantic with LLMs</em>
10
+ <h3>GenAI Agent Framework, the Pydantic way</h3>
11
11
  </div>
12
12
  <div align="center">
13
13
  <a href="https://github.com/pydantic/pydantic-ai/actions/workflows/ci.yml?query=branch%3Amain"><img src="https://github.com/pydantic/pydantic-ai/actions/workflows/ci.yml/badge.svg?event=push" alt="CI"></a>
@@ -24,43 +24,48 @@
24
24
 
25
25
  ---
26
26
 
27
- Pydantic AI is a Python agent framework designed to make it less painful to build production grade applications with Generative AI.
27
+ ### <em>Pydantic AI is a Python agent framework designed to help you quickly, confidently, and painlessly build production grade applications and workflows with Generative AI.</em>
28
28
 
29
- FastAPI revolutionized web development by offering an innovative and ergonomic design, built on the foundation of [Pydantic Validation](https://docs.pydantic.dev).
30
29
 
31
- Similarly, virtually every agent framework and LLM library in Python uses Pydantic Validation, yet when we began to use LLMs in [Pydantic Logfire](https://pydantic.dev/logfire), we couldn't find anything that gave us the same feeling.
30
+ FastAPI revolutionized web development by offering an innovative and ergonomic design, built on the foundation of [Pydantic Validation](https://docs.pydantic.dev) and modern Python features like type hints.
32
31
 
33
- We built Pydantic AI with one simple aim: to bring that FastAPI feeling to GenAI app development.
32
+ Yet despite virtually every Python agent framework and LLM library using Pydantic Validation, when we began to use LLMs in [Pydantic Logfire](https://pydantic.dev/logfire), we couldn't find anything that gave us the same feeling.
33
+
34
+ We built Pydantic AI with one simple aim: to bring that FastAPI feeling to GenAI app and agent development.
34
35
 
35
36
  ## Why use Pydantic AI
36
37
 
37
- - **Built by the Pydantic Team**
38
- Built by the team behind [Pydantic Validation](https://docs.pydantic.dev/latest/) (the validation layer of the OpenAI SDK, the Anthropic SDK, LangChain, LlamaIndex, AutoGPT, Transformers, CrewAI, Instructor and many more).
38
+ 1. **Built by the Pydantic Team**:
39
+ [Pydantic Validation](https://docs.pydantic.dev/latest/) is the validation layer of the OpenAI SDK, the Google ADK, the Anthropic SDK, LangChain, LlamaIndex, AutoGPT, Transformers, CrewAI, Instructor and many more. _Why use the derivative when you can go straight to the source?_ :smiley:
40
+
41
+ 2. **Model-agnostic**:
42
+ Supports virtually every [model](https://ai.pydantic.dev/models/overview) and provider: OpenAI, Anthropic, Gemini, DeepSeek, Grok, Cohere, Mistral, and Perplexity; Azure AI Foundry, Amazon Bedrock, Google Vertex AI, Ollama, LiteLLM, Groq, OpenRouter, Together AI, Fireworks AI, Cerebras, Hugging Face, GitHub, Heroku, Vercel. If your favorite model or provider is not listed, you can easily implement a [custom model](https://ai.pydantic.dev/models/overview#custom-models).
43
+
44
+ 3. **Seamless Observability**:
45
+ Tightly [integrates](https://ai.pydantic.dev/logfire) with [Pydantic Logfire](https://pydantic.dev/logfire), our general-purpose OpenTelemetry observability platform, for real-time debugging, evals-based performance monitoring, and behavior, tracing, and cost tracking. If you already have an observability platform that supports OTel, you can [use that too](https://ai.pydantic.dev/logfire#alternative-observability-backends).
39
46
 
40
- - **Model-agnostic**
41
- Supports OpenAI, Anthropic, Gemini, Deepseek, Ollama, Groq, Cohere, and Mistral, and there is a simple interface to implement support for [other models](https://ai.pydantic.dev/models/).
47
+ 4. **Fully Type-safe**:
48
+ Designed to give your IDE or AI coding agent as much context as possible for auto-completion and [type checking](https://ai.pydantic.dev/agents#static-type-checking), moving entire classes of errors from runtime to write-time for a bit of that Rust "if it compiles, it works" feel.
42
49
 
43
- - **Pydantic Logfire Integration**
44
- Seamlessly [integrates](https://ai.pydantic.dev/logfire/) with [Pydantic Logfire](https://pydantic.dev/logfire) for real-time debugging, performance monitoring, and behavior tracking of your LLM-powered applications.
50
+ 5. **Powerful Evals**:
51
+ Enables you to systematically test and [evaluate](https://ai.pydantic.dev/evals) the performance and accuracy of the agentic systems you build, and monitor the performance over time in Pydantic Logfire.
45
52
 
46
- - **Type-safe**
47
- Designed to make [type checking](https://ai.pydantic.dev/agents/#static-type-checking) as powerful and informative as possible for you.
53
+ 6. **MCP, A2A, and AG-UI**:
54
+ Integrates the [Model Context Protocol](https://ai.pydantic.dev/mcp/client), [Agent2Agent](https://ai.pydantic.dev/a2a), and [AG-UI](https://ai.pydantic.dev/ag-ui) standards to give your agent access to external tools and data, let it interoperate with other agents, and build interactive applications with streaming event-based communication.
48
55
 
49
- - **Python-centric Design**
50
- Leverages Python's familiar control flow and agent composition to build your AI-driven projects, making it easy to apply standard Python best practices you'd use in any other (non-AI) project.
56
+ 7. **Human-in-the-Loop Tool Approval**:
57
+ Easily lets you flag that certain tool calls [require approval](https://ai.pydantic.dev/deferred-tools#human-in-the-loop-tool-approval) before they can proceed, possibly depending on tool call arguments, conversation history, or user preferences.
51
58
 
52
- - **Structured Responses**
53
- Harnesses the power of [Pydantic Validation](https://docs.pydantic.dev/latest/) to [validate and structure](https://ai.pydantic.dev/output/#structured-output) model outputs, ensuring responses are consistent across runs.
59
+ 8. **Durable Execution**:
60
+ Enables you to build [durable agents](https://ai.pydantic.dev/temporal) that can preserve their progress across transient API failures and application errors or restarts, and handle long-running, asynchronous, and human-in-the-loop workflows with production-grade reliability.
54
61
 
55
- - **Dependency Injection System**
56
- Offers an optional [dependency injection](https://ai.pydantic.dev/dependencies/) system to provide data and services to your agent's [system prompts](https://ai.pydantic.dev/agents/#system-prompts), [tools](https://ai.pydantic.dev/tools/) and [output validators](https://ai.pydantic.dev/output/#output-validator-functions).
57
- This is useful for testing and eval-driven iterative development.
62
+ 9. **Streamed Outputs**:
63
+ Provides the ability to [stream](https://ai.pydantic.dev/output#streamed-results) structured output continuously, with immediate validation, ensuring real time access to generated data.
58
64
 
59
- - **Streamed Responses**
60
- Provides the ability to [stream](https://ai.pydantic.dev/output/#streamed-results) LLM outputs continuously, with immediate validation, ensuring rapid and accurate outputs.
65
+ 10. **Graph Support**:
66
+ Provides a powerful way to define [graphs](https://ai.pydantic.dev/graph) using type hints, for use in complex applications where standard control flow can degrade to spaghetti code.
61
67
 
62
- - **Graph Support**
63
- [Pydantic Graph](https://ai.pydantic.dev/graph) provides a powerful way to define graphs using typing hints, this is useful in complex applications where standard control flow can degrade to spaghetti code.
68
+ Realistically though, no list is going to be as convincing as [giving it a try](#next-steps) and seeing how it makes you feel!
64
69
 
65
70
  ## Hello World Example
66
71
 
@@ -71,15 +76,13 @@ from pydantic_ai import Agent
71
76
 
72
77
  # Define a very simple agent including the model to use, you can also set the model when running the agent.
73
78
  agent = Agent(
74
- 'google-gla:gemini-1.5-flash',
75
- # Register a static system prompt using a keyword argument to the agent.
76
- # For more complex dynamically-generated system prompts, see the example below.
77
- system_prompt='Be concise, reply with one sentence.',
79
+ 'anthropic:claude-sonnet-4-0',
80
+ # Register static instructions using a keyword argument to the agent.
81
+ # For more complex dynamically-generated instructions, see the example below.
82
+ instructions='Be concise, reply with one sentence.',
78
83
  )
79
84
 
80
85
  # Run the agent synchronously, conducting a conversation with the LLM.
81
- # Here the exchange should be very short: Pydantic AI will send the system prompt and the user query to the LLM,
82
- # the model will return a text response. See below for a more complex run.
83
86
  result = agent.run_sync('Where does "hello world" come from?')
84
87
  print(result.output)
85
88
  """
@@ -87,9 +90,11 @@ The first known use of "hello, world" was in a 1974 textbook about the C program
87
90
  """
88
91
  ```
89
92
 
90
- _(This example is complete, it can be run "as is")_
93
+ _(This example is complete, it can be run "as is", assuming you've [installed the `pydantic_ai` package](https://ai.pydantic.dev/install))_
91
94
 
92
- Not very interesting yet, but we can easily add "tools", dynamic system prompts, and structured responses to build more powerful agents.
95
+ The exchange will be very short: Pydantic AI will send the instructions and the user prompt to the LLM, and the model will return a text response.
96
+
97
+ Not very interesting yet, but we can easily add [tools](https://ai.pydantic.dev/tools), [dynamic instructions](https://ai.pydantic.dev/agents#instructions), and [structured outputs](https://ai.pydantic.dev/output) to build more powerful agents.
93
98
 
94
99
  ## Tools & Dependency Injection Example
95
100
 
@@ -107,14 +112,14 @@ from bank_database import DatabaseConn
107
112
 
108
113
 
109
114
  # SupportDependencies is used to pass data, connections, and logic into the model that will be needed when running
110
- # system prompt and tool functions. Dependency injection provides a type-safe way to customise the behavior of your agents.
115
+ # instructions and tool functions. Dependency injection provides a type-safe way to customise the behavior of your agents.
111
116
  @dataclass
112
117
  class SupportDependencies:
113
118
  customer_id: int
114
119
  db: DatabaseConn
115
120
 
116
121
 
117
- # This pydantic model defines the structure of the output returned by the agent.
122
+ # This Pydantic model defines the structure of the output returned by the agent.
118
123
  class SupportOutput(BaseModel):
119
124
  support_advice: str = Field(description='Advice returned to the customer')
120
125
  block_card: bool = Field(description="Whether to block the customer's card")
@@ -125,28 +130,28 @@ class SupportOutput(BaseModel):
125
130
  # Agents are generic in the type of dependencies they accept and the type of output they return.
126
131
  # In this case, the support agent has type `Agent[SupportDependencies, SupportOutput]`.
127
132
  support_agent = Agent(
128
- 'openai:gpt-4o',
133
+ 'openai:gpt-5',
129
134
  deps_type=SupportDependencies,
130
135
  # The response from the agent will, be guaranteed to be a SupportOutput,
131
136
  # if validation fails the agent is prompted to try again.
132
137
  output_type=SupportOutput,
133
- system_prompt=(
138
+ instructions=(
134
139
  'You are a support agent in our bank, give the '
135
140
  'customer support and judge the risk level of their query.'
136
141
  ),
137
142
  )
138
143
 
139
144
 
140
- # Dynamic system prompts can make use of dependency injection.
145
+ # Dynamic instructions can make use of dependency injection.
141
146
  # Dependencies are carried via the `RunContext` argument, which is parameterized with the `deps_type` from above.
142
147
  # If the type annotation here is wrong, static type checkers will catch it.
143
- @support_agent.system_prompt
148
+ @support_agent.instructions
144
149
  async def add_customer_name(ctx: RunContext[SupportDependencies]) -> str:
145
150
  customer_name = await ctx.deps.db.customer_name(id=ctx.deps.customer_id)
146
151
  return f"The customer's name is {customer_name!r}"
147
152
 
148
153
 
149
- # `tool` let you register functions which the LLM may call while responding to a user.
154
+ # The `tool` decorator let you register functions which the LLM may call while responding to a user.
150
155
  # Again, dependencies are carried via `RunContext`, any other arguments become the tool schema passed to the LLM.
151
156
  # Pydantic is used to validate these arguments, and errors are passed back to the LLM so it can retry.
152
157
  @support_agent.tool
@@ -187,8 +192,10 @@ async def main():
187
192
 
188
193
  ## Next Steps
189
194
 
190
- To try Pydantic AI yourself, follow the instructions [in the examples](https://ai.pydantic.dev/examples/).
195
+ To try Pydantic AI for yourself, [install it](https://ai.pydantic.dev/install) and follow the instructions [in the examples](https://ai.pydantic.dev/examples/setup).
191
196
 
192
197
  Read the [docs](https://ai.pydantic.dev/agents/) to learn more about building applications with Pydantic AI.
193
198
 
194
199
  Read the [API Reference](https://ai.pydantic.dev/api/agent/) to understand Pydantic AI's interface.
200
+
201
+ Join [Slack](https://logfire.pydantic.dev/docs/join-slack/) or file an issue on [GitHub](https://github.com/pydantic/pydantic-ai/issues) if you have any questions.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pydantic-ai
3
- Version: 1.0.0b1
3
+ Version: 1.0.2
4
4
  Summary: Agent Framework / shim to use Pydantic with LLMs
5
5
  Project-URL: Homepage, https://ai.pydantic.dev
6
6
  Project-URL: Source, https://github.com/pydantic/pydantic-ai
@@ -9,7 +9,7 @@ Project-URL: Changelog, https://github.com/pydantic/pydantic-ai/releases
9
9
  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>
10
10
  License-Expression: MIT
11
11
  License-File: LICENSE
12
- Classifier: Development Status :: 4 - Beta
12
+ Classifier: Development Status :: 5 - Production/Stable
13
13
  Classifier: Framework :: Pydantic
14
14
  Classifier: Framework :: Pydantic :: 2
15
15
  Classifier: Intended Audience :: Developers
@@ -27,11 +27,13 @@ Classifier: Topic :: Internet
27
27
  Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
28
28
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
29
29
  Requires-Python: >=3.10
30
- Requires-Dist: pydantic-ai-slim[ag-ui,anthropic,bedrock,cli,cohere,evals,google,groq,huggingface,logfire,mcp,mistral,openai,retries,temporal,vertexai]==1.0.0b1
30
+ Requires-Dist: pydantic-ai-slim[ag-ui,anthropic,bedrock,cli,cohere,evals,google,groq,huggingface,logfire,mcp,mistral,openai,retries,temporal,vertexai]==1.0.2
31
31
  Provides-Extra: a2a
32
32
  Requires-Dist: fasta2a>=0.4.1; extra == 'a2a'
33
+ Provides-Extra: dbos
34
+ Requires-Dist: pydantic-ai-slim[dbos]==1.0.2; extra == 'dbos'
33
35
  Provides-Extra: examples
34
- Requires-Dist: pydantic-ai-examples==1.0.0b1; extra == 'examples'
36
+ Requires-Dist: pydantic-ai-examples==1.0.2; extra == 'examples'
35
37
  Description-Content-Type: text/markdown
36
38
 
37
39
  <div align="center">
@@ -43,7 +45,7 @@ Description-Content-Type: text/markdown
43
45
  </a>
44
46
  </div>
45
47
  <div align="center">
46
- <em>Agent Framework / shim to use Pydantic with LLMs</em>
48
+ <h3>GenAI Agent Framework, the Pydantic way</h3>
47
49
  </div>
48
50
  <div align="center">
49
51
  <a href="https://github.com/pydantic/pydantic-ai/actions/workflows/ci.yml?query=branch%3Amain"><img src="https://github.com/pydantic/pydantic-ai/actions/workflows/ci.yml/badge.svg?event=push" alt="CI"></a>
@@ -60,43 +62,48 @@ Description-Content-Type: text/markdown
60
62
 
61
63
  ---
62
64
 
63
- Pydantic AI is a Python agent framework designed to make it less painful to build production grade applications with Generative AI.
65
+ ### <em>Pydantic AI is a Python agent framework designed to help you quickly, confidently, and painlessly build production grade applications and workflows with Generative AI.</em>
64
66
 
65
- FastAPI revolutionized web development by offering an innovative and ergonomic design, built on the foundation of [Pydantic Validation](https://docs.pydantic.dev).
66
67
 
67
- Similarly, virtually every agent framework and LLM library in Python uses Pydantic Validation, yet when we began to use LLMs in [Pydantic Logfire](https://pydantic.dev/logfire), we couldn't find anything that gave us the same feeling.
68
+ FastAPI revolutionized web development by offering an innovative and ergonomic design, built on the foundation of [Pydantic Validation](https://docs.pydantic.dev) and modern Python features like type hints.
68
69
 
69
- We built Pydantic AI with one simple aim: to bring that FastAPI feeling to GenAI app development.
70
+ Yet despite virtually every Python agent framework and LLM library using Pydantic Validation, when we began to use LLMs in [Pydantic Logfire](https://pydantic.dev/logfire), we couldn't find anything that gave us the same feeling.
71
+
72
+ We built Pydantic AI with one simple aim: to bring that FastAPI feeling to GenAI app and agent development.
70
73
 
71
74
  ## Why use Pydantic AI
72
75
 
73
- - **Built by the Pydantic Team**
74
- Built by the team behind [Pydantic Validation](https://docs.pydantic.dev/latest/) (the validation layer of the OpenAI SDK, the Anthropic SDK, LangChain, LlamaIndex, AutoGPT, Transformers, CrewAI, Instructor and many more).
76
+ 1. **Built by the Pydantic Team**:
77
+ [Pydantic Validation](https://docs.pydantic.dev/latest/) is the validation layer of the OpenAI SDK, the Google ADK, the Anthropic SDK, LangChain, LlamaIndex, AutoGPT, Transformers, CrewAI, Instructor and many more. _Why use the derivative when you can go straight to the source?_ :smiley:
78
+
79
+ 2. **Model-agnostic**:
80
+ Supports virtually every [model](https://ai.pydantic.dev/models/overview) and provider: OpenAI, Anthropic, Gemini, DeepSeek, Grok, Cohere, Mistral, and Perplexity; Azure AI Foundry, Amazon Bedrock, Google Vertex AI, Ollama, LiteLLM, Groq, OpenRouter, Together AI, Fireworks AI, Cerebras, Hugging Face, GitHub, Heroku, Vercel. If your favorite model or provider is not listed, you can easily implement a [custom model](https://ai.pydantic.dev/models/overview#custom-models).
81
+
82
+ 3. **Seamless Observability**:
83
+ Tightly [integrates](https://ai.pydantic.dev/logfire) with [Pydantic Logfire](https://pydantic.dev/logfire), our general-purpose OpenTelemetry observability platform, for real-time debugging, evals-based performance monitoring, and behavior, tracing, and cost tracking. If you already have an observability platform that supports OTel, you can [use that too](https://ai.pydantic.dev/logfire#alternative-observability-backends).
75
84
 
76
- - **Model-agnostic**
77
- Supports OpenAI, Anthropic, Gemini, Deepseek, Ollama, Groq, Cohere, and Mistral, and there is a simple interface to implement support for [other models](https://ai.pydantic.dev/models/).
85
+ 4. **Fully Type-safe**:
86
+ Designed to give your IDE or AI coding agent as much context as possible for auto-completion and [type checking](https://ai.pydantic.dev/agents#static-type-checking), moving entire classes of errors from runtime to write-time for a bit of that Rust "if it compiles, it works" feel.
78
87
 
79
- - **Pydantic Logfire Integration**
80
- Seamlessly [integrates](https://ai.pydantic.dev/logfire/) with [Pydantic Logfire](https://pydantic.dev/logfire) for real-time debugging, performance monitoring, and behavior tracking of your LLM-powered applications.
88
+ 5. **Powerful Evals**:
89
+ Enables you to systematically test and [evaluate](https://ai.pydantic.dev/evals) the performance and accuracy of the agentic systems you build, and monitor the performance over time in Pydantic Logfire.
81
90
 
82
- - **Type-safe**
83
- Designed to make [type checking](https://ai.pydantic.dev/agents/#static-type-checking) as powerful and informative as possible for you.
91
+ 6. **MCP, A2A, and AG-UI**:
92
+ Integrates the [Model Context Protocol](https://ai.pydantic.dev/mcp/client), [Agent2Agent](https://ai.pydantic.dev/a2a), and [AG-UI](https://ai.pydantic.dev/ag-ui) standards to give your agent access to external tools and data, let it interoperate with other agents, and build interactive applications with streaming event-based communication.
84
93
 
85
- - **Python-centric Design**
86
- Leverages Python's familiar control flow and agent composition to build your AI-driven projects, making it easy to apply standard Python best practices you'd use in any other (non-AI) project.
94
+ 7. **Human-in-the-Loop Tool Approval**:
95
+ Easily lets you flag that certain tool calls [require approval](https://ai.pydantic.dev/deferred-tools#human-in-the-loop-tool-approval) before they can proceed, possibly depending on tool call arguments, conversation history, or user preferences.
87
96
 
88
- - **Structured Responses**
89
- Harnesses the power of [Pydantic Validation](https://docs.pydantic.dev/latest/) to [validate and structure](https://ai.pydantic.dev/output/#structured-output) model outputs, ensuring responses are consistent across runs.
97
+ 8. **Durable Execution**:
98
+ Enables you to build [durable agents](https://ai.pydantic.dev/temporal) that can preserve their progress across transient API failures and application errors or restarts, and handle long-running, asynchronous, and human-in-the-loop workflows with production-grade reliability.
90
99
 
91
- - **Dependency Injection System**
92
- Offers an optional [dependency injection](https://ai.pydantic.dev/dependencies/) system to provide data and services to your agent's [system prompts](https://ai.pydantic.dev/agents/#system-prompts), [tools](https://ai.pydantic.dev/tools/) and [output validators](https://ai.pydantic.dev/output/#output-validator-functions).
93
- This is useful for testing and eval-driven iterative development.
100
+ 9. **Streamed Outputs**:
101
+ Provides the ability to [stream](https://ai.pydantic.dev/output#streamed-results) structured output continuously, with immediate validation, ensuring real time access to generated data.
94
102
 
95
- - **Streamed Responses**
96
- Provides the ability to [stream](https://ai.pydantic.dev/output/#streamed-results) LLM outputs continuously, with immediate validation, ensuring rapid and accurate outputs.
103
+ 10. **Graph Support**:
104
+ Provides a powerful way to define [graphs](https://ai.pydantic.dev/graph) using type hints, for use in complex applications where standard control flow can degrade to spaghetti code.
97
105
 
98
- - **Graph Support**
99
- [Pydantic Graph](https://ai.pydantic.dev/graph) provides a powerful way to define graphs using typing hints, this is useful in complex applications where standard control flow can degrade to spaghetti code.
106
+ Realistically though, no list is going to be as convincing as [giving it a try](#next-steps) and seeing how it makes you feel!
100
107
 
101
108
  ## Hello World Example
102
109
 
@@ -107,15 +114,13 @@ from pydantic_ai import Agent
107
114
 
108
115
  # Define a very simple agent including the model to use, you can also set the model when running the agent.
109
116
  agent = Agent(
110
- 'google-gla:gemini-1.5-flash',
111
- # Register a static system prompt using a keyword argument to the agent.
112
- # For more complex dynamically-generated system prompts, see the example below.
113
- system_prompt='Be concise, reply with one sentence.',
117
+ 'anthropic:claude-sonnet-4-0',
118
+ # Register static instructions using a keyword argument to the agent.
119
+ # For more complex dynamically-generated instructions, see the example below.
120
+ instructions='Be concise, reply with one sentence.',
114
121
  )
115
122
 
116
123
  # Run the agent synchronously, conducting a conversation with the LLM.
117
- # Here the exchange should be very short: Pydantic AI will send the system prompt and the user query to the LLM,
118
- # the model will return a text response. See below for a more complex run.
119
124
  result = agent.run_sync('Where does "hello world" come from?')
120
125
  print(result.output)
121
126
  """
@@ -123,9 +128,11 @@ The first known use of "hello, world" was in a 1974 textbook about the C program
123
128
  """
124
129
  ```
125
130
 
126
- _(This example is complete, it can be run "as is")_
131
+ _(This example is complete, it can be run "as is", assuming you've [installed the `pydantic_ai` package](https://ai.pydantic.dev/install))_
127
132
 
128
- Not very interesting yet, but we can easily add "tools", dynamic system prompts, and structured responses to build more powerful agents.
133
+ The exchange will be very short: Pydantic AI will send the instructions and the user prompt to the LLM, and the model will return a text response.
134
+
135
+ Not very interesting yet, but we can easily add [tools](https://ai.pydantic.dev/tools), [dynamic instructions](https://ai.pydantic.dev/agents#instructions), and [structured outputs](https://ai.pydantic.dev/output) to build more powerful agents.
129
136
 
130
137
  ## Tools & Dependency Injection Example
131
138
 
@@ -143,14 +150,14 @@ from bank_database import DatabaseConn
143
150
 
144
151
 
145
152
  # SupportDependencies is used to pass data, connections, and logic into the model that will be needed when running
146
- # system prompt and tool functions. Dependency injection provides a type-safe way to customise the behavior of your agents.
153
+ # instructions and tool functions. Dependency injection provides a type-safe way to customise the behavior of your agents.
147
154
  @dataclass
148
155
  class SupportDependencies:
149
156
  customer_id: int
150
157
  db: DatabaseConn
151
158
 
152
159
 
153
- # This pydantic model defines the structure of the output returned by the agent.
160
+ # This Pydantic model defines the structure of the output returned by the agent.
154
161
  class SupportOutput(BaseModel):
155
162
  support_advice: str = Field(description='Advice returned to the customer')
156
163
  block_card: bool = Field(description="Whether to block the customer's card")
@@ -161,28 +168,28 @@ class SupportOutput(BaseModel):
161
168
  # Agents are generic in the type of dependencies they accept and the type of output they return.
162
169
  # In this case, the support agent has type `Agent[SupportDependencies, SupportOutput]`.
163
170
  support_agent = Agent(
164
- 'openai:gpt-4o',
171
+ 'openai:gpt-5',
165
172
  deps_type=SupportDependencies,
166
173
  # The response from the agent will, be guaranteed to be a SupportOutput,
167
174
  # if validation fails the agent is prompted to try again.
168
175
  output_type=SupportOutput,
169
- system_prompt=(
176
+ instructions=(
170
177
  'You are a support agent in our bank, give the '
171
178
  'customer support and judge the risk level of their query.'
172
179
  ),
173
180
  )
174
181
 
175
182
 
176
- # Dynamic system prompts can make use of dependency injection.
183
+ # Dynamic instructions can make use of dependency injection.
177
184
  # Dependencies are carried via the `RunContext` argument, which is parameterized with the `deps_type` from above.
178
185
  # If the type annotation here is wrong, static type checkers will catch it.
179
- @support_agent.system_prompt
186
+ @support_agent.instructions
180
187
  async def add_customer_name(ctx: RunContext[SupportDependencies]) -> str:
181
188
  customer_name = await ctx.deps.db.customer_name(id=ctx.deps.customer_id)
182
189
  return f"The customer's name is {customer_name!r}"
183
190
 
184
191
 
185
- # `tool` let you register functions which the LLM may call while responding to a user.
192
+ # The `tool` decorator let you register functions which the LLM may call while responding to a user.
186
193
  # Again, dependencies are carried via `RunContext`, any other arguments become the tool schema passed to the LLM.
187
194
  # Pydantic is used to validate these arguments, and errors are passed back to the LLM so it can retry.
188
195
  @support_agent.tool
@@ -223,8 +230,10 @@ async def main():
223
230
 
224
231
  ## Next Steps
225
232
 
226
- To try Pydantic AI yourself, follow the instructions [in the examples](https://ai.pydantic.dev/examples/).
233
+ To try Pydantic AI for yourself, [install it](https://ai.pydantic.dev/install) and follow the instructions [in the examples](https://ai.pydantic.dev/examples/setup).
227
234
 
228
235
  Read the [docs](https://ai.pydantic.dev/agents/) to learn more about building applications with Pydantic AI.
229
236
 
230
237
  Read the [API Reference](https://ai.pydantic.dev/api/agent/) to understand Pydantic AI's interface.
238
+
239
+ Join [Slack](https://logfire.pydantic.dev/docs/join-slack/) or file an issue on [GitHub](https://github.com/pydantic/pydantic-ai/issues) if you have any questions.
@@ -0,0 +1,6 @@
1
+ README.md,sha256=t2tWkJDwzT_98YeJIS9C4RWpl-Tt_Zu-geAgwkGslA8,11565
2
+ pydantic_ai-1.0.2.dist-info/METADATA,sha256=Y0GjV47OYmghgDTxP2Fr6b00DbPLpqSQoySGdh701D4,13467
3
+ pydantic_ai-1.0.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
4
+ pydantic_ai-1.0.2.dist-info/entry_points.txt,sha256=kbKxe2VtDCYS06hsI7P3uZGxcVC08-FPt1rxeiMpIps,50
5
+ pydantic_ai-1.0.2.dist-info/licenses/LICENSE,sha256=vA6Jc482lEyBBuGUfD1pYx-cM7jxvLYOxPidZ30t_PQ,1100
6
+ pydantic_ai-1.0.2.dist-info/RECORD,,
@@ -1,6 +0,0 @@
1
- README.md,sha256=bRQiIpEWIZOUki4ChFf6CYLwyz1xpbVY-KELGDhaRKA,9980
2
- pydantic_ai-1.0.0b1.dist-info/METADATA,sha256=wX5Q6poa2aR7dOASp4ZPeXDaXC9d9LxmD0JEjfGt_lg,11792
3
- pydantic_ai-1.0.0b1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
4
- pydantic_ai-1.0.0b1.dist-info/entry_points.txt,sha256=kbKxe2VtDCYS06hsI7P3uZGxcVC08-FPt1rxeiMpIps,50
5
- pydantic_ai-1.0.0b1.dist-info/licenses/LICENSE,sha256=vA6Jc482lEyBBuGUfD1pYx-cM7jxvLYOxPidZ30t_PQ,1100
6
- pydantic_ai-1.0.0b1.dist-info/RECORD,,