pydantic-ai 1.0.0b1__py3-none-any.whl → 1.0.1__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.1
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,11 @@ 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.1
31
31
  Provides-Extra: a2a
32
32
  Requires-Dist: fasta2a>=0.4.1; extra == 'a2a'
33
33
  Provides-Extra: examples
34
- Requires-Dist: pydantic-ai-examples==1.0.0b1; extra == 'examples'
34
+ Requires-Dist: pydantic-ai-examples==1.0.1; extra == 'examples'
35
35
  Description-Content-Type: text/markdown
36
36
 
37
37
  <div align="center">
@@ -43,7 +43,7 @@ Description-Content-Type: text/markdown
43
43
  </a>
44
44
  </div>
45
45
  <div align="center">
46
- <em>Agent Framework / shim to use Pydantic with LLMs</em>
46
+ <h3>GenAI Agent Framework, the Pydantic way</h3>
47
47
  </div>
48
48
  <div align="center">
49
49
  <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 +60,48 @@ Description-Content-Type: text/markdown
60
60
 
61
61
  ---
62
62
 
63
- Pydantic AI is a Python agent framework designed to make it less painful to build production grade applications with Generative AI.
63
+ ### <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
64
 
65
- FastAPI revolutionized web development by offering an innovative and ergonomic design, built on the foundation of [Pydantic Validation](https://docs.pydantic.dev).
66
65
 
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.
66
+ 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
67
 
69
- We built Pydantic AI with one simple aim: to bring that FastAPI feeling to GenAI app development.
68
+ 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.
69
+
70
+ We built Pydantic AI with one simple aim: to bring that FastAPI feeling to GenAI app and agent development.
70
71
 
71
72
  ## Why use Pydantic AI
72
73
 
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).
74
+ 1. **Built by the Pydantic Team**:
75
+ [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:
76
+
77
+ 2. **Model-agnostic**:
78
+ 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).
79
+
80
+ 3. **Seamless Observability**:
81
+ 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
82
 
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/).
83
+ 4. **Fully Type-safe**:
84
+ 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
85
 
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.
86
+ 5. **Powerful Evals**:
87
+ 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
88
 
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.
89
+ 6. **MCP, A2A, and AG-UI**:
90
+ 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
91
 
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.
92
+ 7. **Human-in-the-Loop Tool Approval**:
93
+ 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
94
 
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.
95
+ 8. **Durable Execution**:
96
+ 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
97
 
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.
98
+ 9. **Streamed Outputs**:
99
+ 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
100
 
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.
101
+ 10. **Graph Support**:
102
+ 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
103
 
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.
104
+ 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
105
 
101
106
  ## Hello World Example
102
107
 
@@ -107,15 +112,13 @@ from pydantic_ai import Agent
107
112
 
108
113
  # Define a very simple agent including the model to use, you can also set the model when running the agent.
109
114
  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.',
115
+ 'anthropic:claude-sonnet-4-0',
116
+ # Register static instructions using a keyword argument to the agent.
117
+ # For more complex dynamically-generated instructions, see the example below.
118
+ instructions='Be concise, reply with one sentence.',
114
119
  )
115
120
 
116
121
  # 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
122
  result = agent.run_sync('Where does "hello world" come from?')
120
123
  print(result.output)
121
124
  """
@@ -123,9 +126,11 @@ The first known use of "hello, world" was in a 1974 textbook about the C program
123
126
  """
124
127
  ```
125
128
 
126
- _(This example is complete, it can be run "as is")_
129
+ _(This example is complete, it can be run "as is", assuming you've [installed the `pydantic_ai` package](https://ai.pydantic.dev/install))_
127
130
 
128
- Not very interesting yet, but we can easily add "tools", dynamic system prompts, and structured responses to build more powerful agents.
131
+ 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.
132
+
133
+ 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
134
 
130
135
  ## Tools & Dependency Injection Example
131
136
 
@@ -143,14 +148,14 @@ from bank_database import DatabaseConn
143
148
 
144
149
 
145
150
  # 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.
151
+ # instructions and tool functions. Dependency injection provides a type-safe way to customise the behavior of your agents.
147
152
  @dataclass
148
153
  class SupportDependencies:
149
154
  customer_id: int
150
155
  db: DatabaseConn
151
156
 
152
157
 
153
- # This pydantic model defines the structure of the output returned by the agent.
158
+ # This Pydantic model defines the structure of the output returned by the agent.
154
159
  class SupportOutput(BaseModel):
155
160
  support_advice: str = Field(description='Advice returned to the customer')
156
161
  block_card: bool = Field(description="Whether to block the customer's card")
@@ -161,28 +166,28 @@ class SupportOutput(BaseModel):
161
166
  # Agents are generic in the type of dependencies they accept and the type of output they return.
162
167
  # In this case, the support agent has type `Agent[SupportDependencies, SupportOutput]`.
163
168
  support_agent = Agent(
164
- 'openai:gpt-4o',
169
+ 'openai:gpt-5',
165
170
  deps_type=SupportDependencies,
166
171
  # The response from the agent will, be guaranteed to be a SupportOutput,
167
172
  # if validation fails the agent is prompted to try again.
168
173
  output_type=SupportOutput,
169
- system_prompt=(
174
+ instructions=(
170
175
  'You are a support agent in our bank, give the '
171
176
  'customer support and judge the risk level of their query.'
172
177
  ),
173
178
  )
174
179
 
175
180
 
176
- # Dynamic system prompts can make use of dependency injection.
181
+ # Dynamic instructions can make use of dependency injection.
177
182
  # Dependencies are carried via the `RunContext` argument, which is parameterized with the `deps_type` from above.
178
183
  # If the type annotation here is wrong, static type checkers will catch it.
179
- @support_agent.system_prompt
184
+ @support_agent.instructions
180
185
  async def add_customer_name(ctx: RunContext[SupportDependencies]) -> str:
181
186
  customer_name = await ctx.deps.db.customer_name(id=ctx.deps.customer_id)
182
187
  return f"The customer's name is {customer_name!r}"
183
188
 
184
189
 
185
- # `tool` let you register functions which the LLM may call while responding to a user.
190
+ # The `tool` decorator let you register functions which the LLM may call while responding to a user.
186
191
  # Again, dependencies are carried via `RunContext`, any other arguments become the tool schema passed to the LLM.
187
192
  # Pydantic is used to validate these arguments, and errors are passed back to the LLM so it can retry.
188
193
  @support_agent.tool
@@ -223,8 +228,10 @@ async def main():
223
228
 
224
229
  ## Next Steps
225
230
 
226
- To try Pydantic AI yourself, follow the instructions [in the examples](https://ai.pydantic.dev/examples/).
231
+ 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
232
 
228
233
  Read the [docs](https://ai.pydantic.dev/agents/) to learn more about building applications with Pydantic AI.
229
234
 
230
235
  Read the [API Reference](https://ai.pydantic.dev/api/agent/) to understand Pydantic AI's interface.
236
+
237
+ 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.1.dist-info/METADATA,sha256=Qbpw0xlrvqjJrapoRkJ4-mF5iuf7-i0gppthiawmAdY,13384
3
+ pydantic_ai-1.0.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
4
+ pydantic_ai-1.0.1.dist-info/entry_points.txt,sha256=kbKxe2VtDCYS06hsI7P3uZGxcVC08-FPt1rxeiMpIps,50
5
+ pydantic_ai-1.0.1.dist-info/licenses/LICENSE,sha256=vA6Jc482lEyBBuGUfD1pYx-cM7jxvLYOxPidZ30t_PQ,1100
6
+ pydantic_ai-1.0.1.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,,