Skip to content

Conversation

@samuelcolvin
Copy link
Member

@samuelcolvin samuelcolvin commented Sep 16, 2025

To do:


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-chat python 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

@github-actions
Copy link

github-actions bot commented Sep 16, 2025

Docs Preview

commit: e770176
Preview URL: https://b30d1e83-pydantic-ai-previews.pydantic.workers.dev

@DouweM DouweM self-assigned this Sep 16, 2025
@edwinjosechittilappilly

This would be a wonderful addon, looking forward to see it soon in main.

@edwinjosechittilappilly

@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.

Copy link

@183amir 183amir left a 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.

@DouweM DouweM added this to the October 2025 milestone Sep 30, 2025
DouweM added 3 commits October 8, 2025 10:19
# Conflicts:
#	examples/pydantic_ai_examples/chat_app.py
#	pydantic_ai_slim/pydantic_ai/agent/abstract.py
#	pydantic_ai_slim/pydantic_ai/run.py
@DouweM DouweM changed the title Vercel AI Elements types Support Vercel AI Data Stream Protocol Oct 8, 2025
@echarles
Copy link

fyi using this branch for datalayer/jupyter-ai-agents#45

🙏 for working on this.

@lukekh
Copy link
Contributor

lukekh commented Oct 22, 2025

👀 Looking forward to seeing the ag_ui changes drop!

Copy link
Member Author

@samuelcolvin samuelcolvin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all seems good, I'm amazed how big it's got.

I'm a bit unclear on what the public API will be?

part: ModelResponsePart
"""The newly started `ModelResponsePart`."""

previous_part_kind: (
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think put this explanation in the docstring.


ModelResponseStreamEvent = Annotated[
PartStartEvent | PartDeltaEvent | FinalResultEvent, pydantic.Discriminator('event_kind')
PartStartEvent | PartDeltaEvent | PartEndEvent | FinalResultEvent, pydantic.Discriminator('event_kind')
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do think we should have an equivilant of https://docs.pydantic.dev/latest/version-policy/ where we say what we consider a breaking change, and we explicitly say we can change messages without considering a breaking change.

@DouweM DouweM enabled auto-merge (squash) October 29, 2025 22:24
@DouweM DouweM merged commit e300251 into main Oct 29, 2025
30 checks passed
@DouweM DouweM deleted the vercel-ai-chat branch October 29, 2025 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ModelRetry bug with pydantic AI, AG-UI, and Open AI

9 participants