File tree Expand file tree Collapse file tree 1 file changed +13
-11
lines changed
typescript-sdk/integrations/pydantic-ai/examples/server/api Expand file tree Collapse file tree 1 file changed +13
-11
lines changed Original file line number Diff line number Diff line change 77from typing import Any
88from zoneinfo import ZoneInfo
99
10- from pydantic_ai import Agent
10+ from pydantic_ai import Agent , RunDeps
1111
1212
1313@dataclass
14- class ChatState :
15- """State handler for the agentic chat agent."""
16- state : dict [str , Any ]
14+ class State :
15+ pass
1716
1817
19- # Create agent with proper dependency type
20- agent = Agent ('openai:gpt-4o-mini' , deps_type = ChatState )
18+ @dataclass
19+ class Deps (RunDeps ):
20+ """Dependencies that implement StateHandler protocol."""
21+ state : State
2122
22- # Create AG-UI app with default state
23- def create_deps () -> ChatState :
24- """Create default dependencies for the agent."""
25- return ChatState (state = {})
2623
27- app = agent .to_ag_ui (deps = create_deps )
24+ # Create agent with proper dependency type
25+ agent = Agent [str , Deps ]('openai:gpt-4o-mini' , deps_type = Deps )
26+
27+ # Create AG-UI app with proper dataclass instance
28+ deps_instance = Deps (state = State ())
29+ app = agent .to_ag_ui (deps = deps_instance )
2830
2931
3032@agent .tool_plain
You can’t perform that action at this time.
0 commit comments