-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Support Vercel AI Data Stream Protocol #2923
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
Conversation
Docs Preview
|
|
This would be a wonderful addon, looking forward to see it soon in main. |
|
@samuelcolvin can you add it to docs such that it would be integrated as chat service in existing Fullstack apps that uses pydantic-ai as Agent stack. |
183amir
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for this! I left some comments on the code and I will try to test this and get back.
pydantic_ai_slim/pydantic_ai/vercel_ai_elements/request_types.py
Outdated
Show resolved
Hide resolved
pydantic_ai_slim/pydantic_ai/vercel_ai_elements/response_stream.py
Outdated
Show resolved
Hide resolved
pydantic_ai_slim/pydantic_ai/vercel_ai_elements/response_stream.py
Outdated
Show resolved
Hide resolved
pydantic_ai_slim/pydantic_ai/vercel_ai_elements/response_stream.py
Outdated
Show resolved
Hide resolved
# Conflicts: # examples/pydantic_ai_examples/chat_app.py # pydantic_ai_slim/pydantic_ai/agent/abstract.py # pydantic_ai_slim/pydantic_ai/run.py
# Conflicts: # pyproject.toml # tests/models/test_deepseek.py # tests/models/test_huggingface.py # uv.lock
# Conflicts: # docs/ui/ag-ui.md # examples/pydantic_ai_examples/ag_ui/api/agentic_chat.py # examples/pydantic_ai_examples/ag_ui/api/tool_based_generative_ui.py
To do:
clai weborAgent.to_web()?This adds support for Vercel AI Elements streams to Pydantic AI.
There's an example frontend in a separate repo github.com/pydantic/pydantic-ai-chat the plan is to either make that into a more complete template, or release a
pydantic-ai-chatpython library which contains a pre-built react frontend.@DouweM we should rename this to use the proper terminology of the "Vercel AI Data Stream Protocol"
Here's a demo of basic usage:
pydantic-ai-chat.mp4