Skip to content

⚡️ Speed up function tool_from_langchain by 64% #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 90 commits into
base: try-refinement
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
d5ff4a1
Add `StructuredDict` for structured outputs with custom JSON schema (…
fswair Jul 10, 2025
ecbd08b
Fix type annotations for `Agent.iter()` (#2168)
erosennin Jul 10, 2025
b14ce91
Fix chat-app example doc - python code appear twice (#2169)
itayB Jul 10, 2025
6d0e850
fasta2a as `known-third-party` (#2176)
samuelcolvin Jul 10, 2025
78f08f8
Handle DeepSeek reasoning_content in streamed responses (#2174)
tarruda Jul 10, 2025
9b1a89b
chore: skip Gemini tests in local runs (#2181)
stevenh Jul 10, 2025
a5f4b11
chore: support pytest-cov and local reporting (#2179)
stevenh Jul 10, 2025
484022f
chore: disable python 3.9 coverage (#2178)
stevenh Jul 10, 2025
2b7899b
docs: remove note about using GeminiModel instead of GoogleModel (#2184)
Kludex Jul 11, 2025
01b6b2c
Remove unneeded `pragma: lax no cover` (#2177)
samuelcolvin Jul 14, 2025
83c8e01
Fixes for excluding content (#2180)
adtyavrdhn Jul 15, 2025
6179a1f
docs: Add Agenta integration documentation (#2192)
mmabrouk Jul 15, 2025
c325b7c
Mention agents instead of models in MCP servers documentation (#2160)
Viicos Jul 15, 2025
1130748
`duckduckgo-search` is renamed to `ddgs` (#2172)
basnijholt Jul 15, 2025
41640aa
Add base64 encoding to `tool_return_ta` (#2186)
adtyavrdhn Jul 15, 2025
46aa248
Bugfix: avoid race condition when refreshing google token (#2100)
JadHADDAD92 Jul 15, 2025
c94cc03
fix: a2a docs dependency (#2216)
stevenh Jul 16, 2025
f9f1c03
feat: Add output function tracing (#2191)
bitnahian Jul 16, 2025
4d755d2
Add Hugging Face as a provider (#1911)
hanouticelina Jul 16, 2025
849aa4c
Toolsets (#2024)
DouweM Jul 16, 2025
64b64a5
[openai] Remove incorrect tool call id from tool call delta (#2210)
naveen-corpusant Jul 16, 2025
4eff63c
Remove old Google models (#2220)
DouweM Jul 16, 2025
4193208
Add Douwe to maintainers (#2221)
DouweM Jul 16, 2025
4a47596
[Docs] List Hugging Face Inference Provider (#2229)
hanouticelina Jul 17, 2025
479b346
change clai default model to gpt-4.1 (#2227)
samuelcolvin Jul 17, 2025
420166d
fix: allow empty content for TextPart on GoogleModel (#2203)
caesarnine Jul 17, 2025
7bd03fc
chore: add experimetal GitHub agent (#2232)
Kludex Jul 17, 2025
883e1ea
update logos, favicon and brand names (#2193)
GSemikozov Jul 17, 2025
e6396cc
⚡️ Speed up method `AgentRunResult._set_output_tool_return` by 18798%…
misrasaurabh1 Jul 17, 2025
8f63ba3
⚡️ Speed up method `Usage.opentelemetry_attributes` by 85% (#2198)
misrasaurabh1 Jul 17, 2025
61f5260
Nicer errors under the capture_run_messages context (#2219)
alonme Jul 17, 2025
c568ee9
Add OpenAI o1-pro, o3-pro, o3-deep-research, computer-use models (#2234)
zachmayer Jul 17, 2025
0b3bf86
chore(mistral): disable model_fields deprecation warning (#2224)
stevenh Jul 17, 2025
490c3b4
Toolsets public interface and docs tweaks (#2241)
DouweM Jul 17, 2025
babc23b
add identifier field to BinaryContent class (#2231)
GDaamn Jul 18, 2025
3c43c2d
Add grok-4 and groq kimi-k2 models (#2235)
zachmayer Jul 18, 2025
431ec33
Support AG-UI protocol for frontend-agent communication (#2223)
stevenh Jul 18, 2025
01c550c
chore: Fix inconsistent docs example output and fix variable name (#2…
DouweM Jul 18, 2025
7d50564
Add `async with self` in `agent_to_a2a` (#2266)
Kludex Jul 21, 2025
9ca4bca
Fix include_content not working as expected (#2206)
adtyavrdhn Jul 21, 2025
09bd7dd
Support streamable HTTP in mcp-run-python (#2230)
Kigstn Jul 21, 2025
091c499
change `format_as_xml` defaults (#2228)
samuelcolvin Jul 21, 2025
87871b3
Fix LLMJudge input handling to preserve BinaryContent as separate mes…
adtyavrdhn Jul 21, 2025
772af1d
validate OpenAI responses (#2226)
samuelcolvin Jul 22, 2025
c78fa3f
Remove duplicate field on GeminiModelSettings (#2269)
strawgate Jul 22, 2025
3ceff58
Fix AG-UI shared state example (#2272)
stevenh Jul 22, 2025
932c888
Correct code snippet for native output (#2271)
minhduc0711 Jul 22, 2025
2b180f3
chore: simplify output function call with model retry (#2273)
bitnahian Jul 22, 2025
8112002
Fix pydantic-evals panel rendering with evaluators (#2274)
dmontagu Jul 22, 2025
66f1868
Reduce duplication between StreamedRunResult and AgentStream (#2275)
DouweM Jul 22, 2025
8a00611
⚡️ Speed up function `tool_from_langchain` by 64%
codeflash-ai[bot] Jul 22, 2025
0f46928
Fix mp3 handling (#2279)
dmontagu Jul 23, 2025
a589f30
fix: use `FileUrl.format` to find the extension (#2280)
Kludex Jul 23, 2025
07e46b3
chore: add `CLAUDE.md` (#2281)
Kludex Jul 23, 2025
1e18729
Handle built-in tool errors better in tool registration (#2252)
fswair Jul 23, 2025
f3ad3e6
Enable URL and binary PDF for Mistral (#2267)
pintaf Jul 23, 2025
0b3d020
Speed up function `_estimate_string_tokens` (#2156)
misrasaurabh1 Jul 23, 2025
903f11e
Ignore empty text alongside tool calls when streaming from Ollama (#2…
DouweM Jul 23, 2025
b686001
Handle `None` `created` timestamp coming from OpenRouter API (#2247)
R0boji Jul 23, 2025
e295e5e
Rename `MCPServer` `sse_read_timeout` to `read_timeout` and pass to `…
AntSan813 Jul 23, 2025
a0c3abb
Update cohere and MCP, add support for MCP ResourceLink returned from…
medaminezghal Jul 24, 2025
2af4db6
Add Vercel AI Gateway provider (#2277)
joshualipman123 Jul 24, 2025
7eb4491
Parse '<think>' tags in streamed text as thinking parts (#2290)
DouweM Jul 24, 2025
da80f5d
Fix AG-UI parallel tool calls (#2301)
DouweM Jul 24, 2025
fc6a2b2
Support passing files uploaded to Gemini Files API and setting custom…
dprov Jul 24, 2025
6d8a4df
Update MCP docs to show you can pass SSL/TLS options via the `http_cl…
assadyousuf Jul 24, 2025
7728c2a
Add MoonshotAI provider with Kimi-K2 model support (#2211)
zachmayer Jul 24, 2025
bc4facd
Include ThinkingPart in messages.md API documentation graph (#2299)
lfloeer Jul 24, 2025
94b4305
Fix docs build failure by adding MoonshotAIProvider to API docs (#2304)
DouweM Jul 24, 2025
4104aca
Fix initial tool call args not being streamed with AG-UI (#2303)
DouweM Jul 24, 2025
41dd069
Ignore leading whitespace when streaming text, fixing run_stream + Ol…
DouweM Jul 24, 2025
ff0f6a9
refine changes
KRRT7 Jul 24, 2025
5cf372a
fix: close initialized MCP server if any MCP server fails to initaliz…
hartungstenio Jul 25, 2025
4941468
Add tenacity utilities/integration for improved retry handling (#2282)
dmontagu Jul 25, 2025
6e60677
Adding thinkingpart to otel_events in ModelResponse (#2237)
adtyavrdhn Jul 25, 2025
6207ac6
Add Claude Code action so we can tag @claude on issues and PRs (#2315)
DouweM Jul 25, 2025
806d56d
Fix: TypeError in MCPServerSSE due to improper initialization (#2319)
tradeqvest Jul 28, 2025
33aaef1
Pin tokenizers <= 0.21.2 as later 0.21.4 doesn't have required wheels…
DouweM Jul 28, 2025
86d70b5
Fix: AG-UI assistant text and tool call order (#2328)
ChuckJonas Jul 28, 2025
004d63b
Revert "Pin tokenizers <= 0.21.2 as later 0.21.4 doesn't have require…
DouweM Jul 28, 2025
0260a31
Allow `default` in tool schema with Gemini (#2309)
strawgate Jul 28, 2025
168680a
Fix AgentStream.stream_output and StreamedRunResult.stream_structured…
DouweM Jul 28, 2025
2fca506
Ensure AG-UI state is isolated between requests. (#2343)
DouweM Jul 28, 2025
ab92e67
Refine retry logic for parallel tool calling (#2317)
DouweM Jul 28, 2025
362dcbf
Set up environment for @claude, allow it make and uv, and reading CI …
DouweM Jul 29, 2025
8f20f9b
Remove older deprecated models of Anthropic (#2345)
medaminezghal Jul 29, 2025
c7a3591
Revert "Remove older deprecated models of Anthropic" (#2358)
DouweM Jul 29, 2025
3e1f634
Fix parallel tool calling with tools returning ToolReturn with conten…
DouweM Jul 29, 2025
a145a85
revert changes
misrasaurabh1 Jul 30, 2025
d7506ec
Merge branch 'main' into codeflash/optimize-tool_from_langchain-mdexqq2r
misrasaurabh1 Jul 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/agent.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: GitHub Agent

on:
issues:
types: [opened]

jobs:
agent:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: View the github context
run: echo "$GITHUB_CONTEXT"
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
- name: Run GitHub Agent
uses: kludex/github-agent@main
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,10 @@ jobs:
enable-cache: true

- run: uv sync --package pydantic-ai-slim --only-dev
- run: rm coverage/.coverage.*-py3.9-* # Exclude 3.9 coverage as it gets the wrong line numbers, causing invalid failures.
- run: uv run coverage combine coverage

- run: uv run coverage html --show-contexts --title "PydanticAI coverage for ${{ github.sha }}"
- run: uv run coverage html --show-contexts --title "Pydantic AI coverage for ${{ github.sha }}"

- name: Store coverage html
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -416,7 +417,7 @@ jobs:
env:
VERSION: ${{ needs.release.outputs.package-version }}
TWEET: |
PydanticAI version {version} is out! 🎉
Pydantic AI version {version} is out! 🎉

https://github.com/pydantic/pydantic-ai/releases/tag/v{version}
TWITTER_CONSUMER_KEY: ${{ secrets.TWITTER_CONSUMER_KEY }}
Expand Down
58 changes: 58 additions & 0 deletions .github/workflows/claude.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Claude Code

on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
issues:
types: [opened, assigned]
pull_request_review:
types: [submitted]

env:
UV_PYTHON: 3.13
UV_FROZEN: "1"

jobs:
claude-code-action:
if: |
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
(github.event_name == 'issues' && contains(github.event.issue.body, '@claude'))
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
issues: read
id-token: write
actions: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1

- uses: astral-sh/setup-uv@v5
with:
enable-cache: true

- uses: denoland/setup-deno@v2
with:
deno-version: v2.x

- run: uv tool install pre-commit

- run: make install

- name: Run Claude PR Action
uses: anthropics/claude-code-action@beta
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
timeout_minutes: "60"
additional_permissions: |
actions: read
allowed_tools: |
Bash(make:*)
Bash(uv:*)
37 changes: 0 additions & 37 deletions .github/workflows/codeflash.yaml

This file was deleted.

1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ examples/pydantic_ai_examples/.chat_app_messages.sqlite
.vscode/
/question_graph_history.json
/docs-site/.wrangler/
/CLAUDE.md
node_modules/
**.idea/
.coverage*
Expand Down
127 changes: 127 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Development Commands

### Core Development Tasks
- **Install dependencies**: `make install` (requires uv, pre-commit, and deno)
- **Run all checks**: `make` (format, lint, typecheck, test with coverage)
- **Format code**: `make format`
- **Lint code**: `make lint`
- **Type checking**: `make typecheck` (uses pyright) or `make typecheck-both` (pyright + mypy)
- **Run tests**: `make test` (with coverage) or `make test-fast` (parallel, no coverage)
- **Build docs**: `make docs` or `make docs-serve` (local development)

### Single Test Commands
- **Run specific test**: `uv run pytest tests/test_agent.py::test_function_name -v`
- **Run test file**: `uv run pytest tests/test_agent.py -v`
- **Run with debug**: `uv run pytest tests/test_agent.py -v -s`

### Multi-Python Testing
- **Install all Python versions**: `make install-all-python`
- **Test all Python versions**: `make test-all-python`

## Project Architecture

### Core Components

**Agent System (`pydantic_ai_slim/pydantic_ai/agent.py`)**
- `Agent[AgentDepsT, OutputDataT]`: Main orchestrator class with generic types for dependency injection and output validation
- Entry points: `run()`, `run_sync()`, `run_stream()` methods
- Handles tool management, system prompts, and model interaction

**Model Integration (`pydantic_ai_slim/pydantic_ai/models/`)**
- Unified interface across providers: OpenAI, Anthropic, Google, Groq, Cohere, Mistral, Bedrock, HuggingFace
- Model strings: `"openai:gpt-4o"`, `"anthropic:claude-3-5-sonnet"`, `"google:gemini-1.5-pro"`
- `ModelRequestParameters` for configuration, `StreamedResponse` for streaming

**Graph-based Execution (`pydantic_graph/` + `_agent_graph.py`)**
- State machine execution through: `UserPromptNode` → `ModelRequestNode` → `CallToolsNode`
- `GraphAgentState` maintains message history and usage tracking
- `GraphRunContext` provides execution context

**Tool System (`tools.py`, `toolsets/`)**
- `@agent.tool` decorator for function registration
- `RunContext[AgentDepsT]` provides dependency injection in tools
- Support for sync/async functions with automatic schema generation

**Output Handling**
- `TextOutput`: Plain text responses
- `ToolOutput`: Structured data via tool calls
- `NativeOutput`: Provider-specific structured output
- `PromptedOutput`: Prompt-based structured extraction

### Key Design Patterns

**Dependency Injection**
```python
@dataclass
class MyDeps:
database: DatabaseConn

agent = Agent('openai:gpt-4o', deps_type=MyDeps)

@agent.tool
async def get_data(ctx: RunContext[MyDeps]) -> str:
return await ctx.deps.database.fetch_data()
```

**Type-Safe Agents**
```python
class OutputModel(BaseModel):
result: str
confidence: float

agent: Agent[MyDeps, OutputModel] = Agent(
'openai:gpt-4o',
deps_type=MyDeps,
output_type=OutputModel
)
```

## Workspace Structure

This is a uv workspace with multiple packages:
- **`pydantic_ai_slim/`**: Core framework (minimal dependencies)
- **`pydantic_evals/`**: Evaluation system
- **`pydantic_graph/`**: Graph execution engine
- **`examples/`**: Example applications
- **`clai/`**: CLI tool
- **`mcp-run-python/`**: MCP server implementation (Deno/TypeScript)

## Testing Strategy

- **Unit tests**: `tests/` directory with comprehensive model and component coverage
- **VCR cassettes**: `tests/cassettes/` for recorded LLM API interactions
- **Test models**: Use `TestModel` for deterministic testing
- **Examples testing**: `tests/test_examples.py` validates all documentation examples
- **Multi-version testing**: Python 3.9-3.13 support

## Key Configuration Files

- **`pyproject.toml`**: Main workspace configuration with dependency groups
- **`pydantic_ai_slim/pyproject.toml`**: Core package with model optional dependencies
- **`Makefile`**: Development task automation
- **`uv.lock`**: Locked dependencies for reproducible builds

## Important Implementation Notes

- **Model Provider Integration**: Each provider in `models/` directory implements the `Model` abstract base class
- **Message System**: Vendor-agnostic message format in `messages.py` with rich content type support
- **Streaming Architecture**: Real-time response processing with validation during streaming
- **Error Handling**: Specific exception types with retry mechanisms at multiple levels
- **OpenTelemetry Integration**: Built-in observability support

## Documentation Development

- **Local docs**: `make docs-serve` (serves at http://localhost:8000)
- **Docs source**: `docs/` directory (MkDocs with Material theme)
- **API reference**: Auto-generated from docstrings using mkdocstrings

## Dependencies Management

- **Package manager**: uv (fast Python package manager)
- **Lock file**: `uv.lock` (commit this file)
- **Sync command**: `make sync` to update dependencies
- **Optional extras**: Define groups in `pyproject.toml` optional-dependencies
62 changes: 31 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<a href="https://ai.pydantic.dev/">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://ai.pydantic.dev/img/pydantic-ai-dark.svg">
<img src="https://ai.pydantic.dev/img/pydantic-ai-light.svg" alt="PydanticAI">
<img src="https://ai.pydantic.dev/img/pydantic-ai-light.svg" alt="Pydantic AI">
</picture>
</a>
</div>
Expand All @@ -24,47 +24,47 @@

---

PydanticAI is a Python agent framework designed to make it less painful to build production grade applications with Generative AI.
Pydantic AI is a Python agent framework designed to make it less painful to build production grade applications with Generative AI.

FastAPI revolutionized web development by offering an innovative and ergonomic design, built on the foundation of [Pydantic](https://docs.pydantic.dev).
FastAPI revolutionized web development by offering an innovative and ergonomic design, built on the foundation of [Pydantic Validation](https://docs.pydantic.dev).

Similarly, virtually every agent framework and LLM library in Python uses Pydantic, 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.
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.

We built PydanticAI with one simple aim: to bring that FastAPI feeling to GenAI app development.
We built Pydantic AI with one simple aim: to bring that FastAPI feeling to GenAI app development.

## Why use PydanticAI
## Why use Pydantic AI

* __Built by the Pydantic Team__
Built by the team behind [Pydantic](https://docs.pydantic.dev/latest/) (the validation layer of the OpenAI SDK, the Anthropic SDK, LangChain, LlamaIndex, AutoGPT, Transformers, CrewAI, Instructor and many more).
- **Built by the Pydantic Team**
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).

* __Model-agnostic__
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/).
- **Model-agnostic**
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/).

* __Pydantic Logfire Integration__
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.
- **Pydantic Logfire Integration**
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.

* __Type-safe__
Designed to make [type checking](https://ai.pydantic.dev/agents/#static-type-checking) as powerful and informative as possible for you.
- **Type-safe**
Designed to make [type checking](https://ai.pydantic.dev/agents/#static-type-checking) as powerful and informative as possible for you.

* __Python-centric Design__
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.
- **Python-centric Design**
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.

* __Structured Responses__
Harnesses the power of [Pydantic](https://docs.pydantic.dev/latest/) to [validate and structure](https://ai.pydantic.dev/output/#structured-output) model outputs, ensuring responses are consistent across runs.
- **Structured Responses**
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.

* __Dependency Injection System__
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).
This is useful for testing and eval-driven iterative development.
- **Dependency Injection System**
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).
This is useful for testing and eval-driven iterative development.

* __Streamed Responses__
Provides the ability to [stream](https://ai.pydantic.dev/output/#streamed-results) LLM outputs continuously, with immediate validation, ensuring rapid and accurate outputs.
- **Streamed Responses**
Provides the ability to [stream](https://ai.pydantic.dev/output/#streamed-results) LLM outputs continuously, with immediate validation, ensuring rapid and accurate outputs.

* __Graph Support__
[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.
- **Graph Support**
[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.

## Hello World Example

Here's a minimal example of PydanticAI:
Here's a minimal example of Pydantic AI:

```python
from pydantic_ai import Agent
Expand All @@ -78,7 +78,7 @@ agent = Agent(
)

# Run the agent synchronously, conducting a conversation with the LLM.
# Here the exchange should be very short: PydanticAI will send the system prompt and the user query to the LLM,
# Here the exchange should be very short: Pydantic AI will send the system prompt and the user query to the LLM,
# the model will return a text response. See below for a more complex run.
result = agent.run_sync('Where does "hello world" come from?')
print(result.output)
Expand All @@ -93,7 +93,7 @@ Not very interesting yet, but we can easily add "tools", dynamic system prompts,

## Tools & Dependency Injection Example

Here is a concise example using PydanticAI to build a support agent for a bank:
Here is a concise example using Pydantic AI to build a support agent for a bank:

**(Better documented example [in the docs](https://ai.pydantic.dev/#tools-dependency-injection-example))**

Expand Down Expand Up @@ -187,8 +187,8 @@ async def main():

## Next Steps

To try PydanticAI yourself, follow the instructions [in the examples](https://ai.pydantic.dev/examples/).
To try Pydantic AI yourself, follow the instructions [in the examples](https://ai.pydantic.dev/examples/).

Read the [docs](https://ai.pydantic.dev/agents/) to learn more about building applications with PydanticAI.
Read the [docs](https://ai.pydantic.dev/agents/) to learn more about building applications with Pydantic AI.

Read the [API Reference](https://ai.pydantic.dev/api/agent/) to understand PydanticAI's interface.
Read the [API Reference](https://ai.pydantic.dev/api/agent/) to understand Pydantic AI's interface.
Loading
Loading