Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite9a0669

Browse files
committed
Move AG-UI example readme into docs/examples and add to sidebar
1 parente484420 commite9a0669

File tree

2 files changed

+47
-13
lines changed

2 files changed

+47
-13
lines changed

‎examples/pydantic_ai_examples/ag_ui/README.mdrenamed to ‎docs/examples/ag-ui.md

Lines changed: 46 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
#PydanticAIAG-UI Examples
1+
#Agent User Interaction (AG-UI) Protocol
22

3-
This example uses PydanticAI agents with the[AG-UI Dojo](https://github.com/ag-ui-protocol/ag-ui/tree/main/typescript-sdk/apps/dojo) example app.
3+
This example uses Pydantic AI agents with the[AG-UI Dojo](https://github.com/ag-ui-protocol/ag-ui/tree/main/typescript-sdk/apps/dojo) example app.
4+
5+
See the[AG-UI docs](../ag-ui.md) for more information about the AG-UI integration.
46

57
##Prerequisites
68

79
1. An[OpenAI API key](https://help.openai.com/en/articles/4936850-where-do-i-find-my-openai-api-key)
8-
2. A clone of the[AG-UI repository](https://github.com/ag-ui-protocol/ag-ui)
910

1011
##Running
1112

@@ -20,28 +21,36 @@ This example uses PydanticAI agents with the [AG-UI Dojo](https://github.com/ag-
2021
2. Run the example AG-UI app
2122

2223
```shell
24+
export OPENAI_API_KEY=<your api key>
2325
python/uv-run -m pydantic_ai_examples.ag_ui
2426
```
2527

2628
2. Run the AG-UI Dojo example frontend
27-
1. Move to the cloned AG-UI repository directory
28-
2. In the`typescript-sdk/integrations/pydantic-ai` directory, copy`.env-sample` to`.env`
29-
3. Open itin your editor andset`OPENAI_API_KEY` to a valid OpenAI key
30-
4. Open a terminalin the`typescript-sdk` directory
31-
5. Run the Dojo app following the [official instructions](https://github.com/ag-ui-protocol/ag-ui/tree/main/typescript-sdk/apps/dojo#development-setup)
29+
1. Clone the [AG-UI repository](https://github.com/ag-ui-protocol/ag-ui)
30+
31+
```shell
32+
git clone https://github.com/ag-ui-protocol/ag-ui.git
33+
```
34+
2. Move to the`ag-ui/typescript-sdk` directory
35+
36+
```shell
37+
cd ag-ui/typescript-sdk
38+
```
39+
40+
3. Run the Dojo app following the [official instructions](https://github.com/ag-ui-protocol/ag-ui/tree/main/typescript-sdk/apps/dojo#development-setup)
3241

33-
3.Finally visit<http://localhost:3000/pydantic-ai>
42+
3.Visit<http://localhost:3000/pydantic-ai> to see the appin action!
3443

3544
## Feature Demos
3645

3746
### [Agentic Chat](http://localhost:3000/pydantic-ai/feature/agentic_chat)
3847

39-
This demonstrates a basic agent interaction includingPydanticAI server side
48+
This demonstrates a basic agent interaction includingPydantic AI server side
4049
tools and AG-UI client side tools.
4150

4251
#### Agent Tools
4352

44-
-`time` -PydanticAI tool to check the currenttimefor atime zone
53+
-`time` -Pydantic AI tool to check the currenttimefor atime zone
4554
-`background` - AG-UI tool toset the background color of the client window
4655

4756
#### Agent Prompts
@@ -54,7 +63,7 @@ What is the time in New York?
5463
Change the background to blue
5564
```
5665

57-
A complex example which mixes both AG-UI andPydanticAI tools:
66+
A complex example which mixes both AG-UI andPydantic AI tools:
5867

5968
```text
6069
Perform the following steps, waitingfor the response of each step before continuing:
@@ -64,6 +73,10 @@ Perform the following steps, waiting for the response of each step before contin
6473
4. Report how long the backgroundset took by diffing the twotimes
6574
```
6675

76+
#### Code
77+
78+
```snippet {path="/examples/pydantic_ai_examples/ag_ui/api/agentic_chat.py"}```
79+
6780
### [Agentic Generative UI](http://localhost:3000/pydantic-ai/feature/agentic_generative_ui)
6881

6982
Demonstrates a long running task where the agent sends updates to the frontend
@@ -75,6 +88,10 @@ to let the user know what's happening.
7588
Create a plan for breakfast and execute it
7689
```
7790
91+
#### Code
92+
93+
```snippet {path="/examples/pydantic_ai_examples/ag_ui/api/agentic_generative_ui.py"}```
94+
7895
### [Human in the Loop](http://localhost:3000/pydantic-ai/feature/human_in_the_loop)
7996
8097
Demonstrates simple human in the loop workflow where the agent comes up with a
@@ -90,6 +107,10 @@ plan and the user can approve it using checkboxes.
90107
Generate a list of steps for cleaning a car for me to review
91108
```
92109
110+
#### Code
111+
112+
```snippet {path="/examples/pydantic_ai_examples/ag_ui/api/human_in_the_loop.py"}```
113+
93114
### [Predictive State Updates](http://localhost:3000/pydantic-ai/feature/predictive_state_updates)
94115
95116
Demonstrates how to use the predictive state updates feature to update the state
@@ -99,7 +120,7 @@ confirmation.
99120
#### Story Tools
100121
101122
- `write_document` - AG-UI tool to write the document to a window
102-
- `document_predict_state` -PydanticAI tool that enables document state
123+
- `document_predict_state` -Pydantic AI tool that enables document state
103124
prediction for the `write_document` tool
104125
105126
This also shows how to use custom instructions based on shared state information.
@@ -118,6 +139,10 @@ Agent prompt
118139
Help me complete my story about bruce the dog, is should be no longer than a sentence.
119140
```
120141
142+
#### Code
143+
144+
```snippet {path="/examples/pydantic_ai_examples/ag_ui/api/predictive_state_updates.py"}```
145+
121146
### [Shared State](http://localhost:3000/pydantic-ai/feature/shared_state)
122147
123148
Demonstrates how to use the shared state between the UI and the agent.
@@ -135,6 +160,10 @@ instructions for the agent to follow and send to the client using a AG-UI tool.
135160
1. Customise the basic settings of your recipe
136161
2. Click `Improve with AI`
137162
163+
#### Code
164+
165+
```snippet {path="/examples/pydantic_ai_examples/ag_ui/api/shared_state.py"}```
166+
138167
### [Tool Based Generative UI](http://localhost:3000/pydantic-ai/feature/tool_based_generative_ui)
139168
140169
Demonstrates customised rendering for tool output with used confirmation.
@@ -148,3 +177,7 @@ Demonstrates customised rendering for tool output with used confirmation.
148177
```text
149178
Generate a haiku about formula 1
150179
```
180+
181+
#### Code
182+
183+
```snippet {path="/examples/pydantic_ai_examples/ag_ui/api/tool_based_generative_ui.py"}```

‎mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ nav:
6464
-examples/chat-app.md
6565
-examples/question-graph.md
6666
-examples/slack-lead-qualifier.md
67+
-examples/ag-ui.md
6768
-API Reference:
6869
-api/ag_ui.md
6970
-api/agent.md

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp