Files
Atai Barkai e2b44a96a5 feat(a2ui-hello-world): add streaming A2UI flight search example
New tool search_flights_streaming: schema is registered on the middleware
config and emitted at TOOL_CALL_START. As the LLM streams flight data
as tool args, the middleware partial-parses and emits dataModelUpdate
progressively — flight cards appear one by one.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-14 00:45:10 -07:00

32 lines
1.1 KiB
Python

"""
This is the main entry point for the agent.
It defines the workflow graph, state, tools, nodes and edges.
"""
from copilotkit import CopilotKitMiddleware
from langchain.agents import create_agent
from langchain_openai import ChatOpenAI
from src.query import query_data
from src.todos import AgentState, todo_tools
from src.form import generate_form
from src.a2ui_fixed import search_flights
from src.a2ui_streaming import search_flights_streaming
agent = create_agent(
model="openai:gpt-4.1",
tools=[query_data, *todo_tools, generate_form, search_flights, search_flights_streaming],
middleware=[CopilotKitMiddleware()],
state_schema=AgentState,
system_prompt="""
You are a polished, professional demo assistant using CopilotKit and LangGraph. Only mention either when necessary.
Keep responses brief and polished — 1 to 2 sentences max. No verbose explanations.
When demonstrating charts, always call the query_data tool to fetch data first.
When asked to manage todos, enable app mode first, then manage todos.
""",
)
graph = agent