Build and extend AI chat agents with a shared UI. This workshop includes:
- a Next.js frontend with Vercel AI SDK streaming
- a TypeScript agent example built with AI SDK
- a Python agent example built with Pydantic AI
This repo works on macOS, Linux, and Windows.
Install these first:
- Node.js 20+ (includes
npm) - Python 3.12+
uvfor the Python environment- an OpenAI API key
curlavailable on yourPATHfor the preparation script
Create a .env.local file in the project root:
OPENAI_API_KEY=your_key_hereThen run:
npm run setup
npm run prepare
npm run devnpm run setup installs the frontend, shared JavaScript dependencies, and sets up the Python environment.
npm run prepare installs the git hooks and downloads the workshop data/docs.
npm run dev starts the Next.js app on http://localhost:3000 and the Python API on http://127.0.0.1:8000.
Use the arXiv agent as the reference implementation.
- Create a route in
app/api/agents/<your-agent>/[conversationId]/route.ts. - In that route, convert incoming UI messages, create your agent, and return a streamed UI response.
- Implement the agent itself in
lib/<your-agent>.tswith its model, instructions, and tools. - Register the new agent in
lib/agents.tsso it appears in the UI. - If your tools send structured data to the frontend, add the data part types and panel UI alongside the existing agent components.
Good starting points:
app/api/agents/arxiv/[conversationId]/route.tslib/arxiv-agent.tslib/agents.ts
Use the SQL analyst as the reference implementation.
- Define or update your Pydantic AI agent in
agent/src/agent/agent.py. - Add tools there for the work your agent needs to do.
- Reuse the FastAPI chat wiring in
agent/src/agent/chat_router.pyandagent/src/agent/server.py. - Point the frontend at your Python endpoint from
lib/agents.ts. - If your tools need to update the UI with structured results, return
ToolReturnmetadata and render it in a frontend panel.
Good starting points:
agent/src/agent/agent.pyagent/src/agent/chat_router.pyagent/src/agent/server.pylib/agents.ts
- Change the agent instructions.
- Add or remove tools.
- Swap the model.
- Add a new data panel for agent-specific output.
The quickest path is to copy one of the two existing agents, rename it, and then narrow it to your use case.
If you want extension ideas, see INSPIRATION.md.