Spaces:
Sleeping
Sleeping
| from dataclasses import dataclass | |
| from typing import Dict, Any, List | |
| import asyncio | |
| class ChatDeps: | |
| """Dependencies injected into Pydantic AI runs for interactive TUI tools.""" | |
| event_queue: asyncio.Queue | |
| input_queue: asyncio.Queue | |
| class ChatEvent: | |
| """Base class for all agent loop events.""" | |
| pass | |
| class AgentRequiresUserInput(ChatEvent): | |
| """The agent needs the TUI to gather input from the user.""" | |
| tool_name: str | |
| prompt: str | |
| options: List[str] | |
| class AgentExecuteCommand(ChatEvent): | |
| """The agent wants to execute a TUI slash command.""" | |
| command_name: str | |
| args: List[str] | |
| class AgentThinking(ChatEvent): | |
| """The agent is processing or waiting for a response.""" | |
| message: str = "Thinking..." | |
| class AgentToolStart(ChatEvent): | |
| """The agent has decided to call a tool.""" | |
| tool_name: str | |
| args: Dict[str, Any] | |
| class AgentToolEnd(ChatEvent): | |
| """The agent has finished executing a tool.""" | |
| tool_name: str | |
| result: str | |
| class AgentToolOutput(ChatEvent): | |
| """Streaming output from a running tool (e.g., bash stdout, file contents).""" | |
| tool_name: str | |
| content: str | |
| is_error: bool = False | |
| class AgentThinkingChunk(ChatEvent): | |
| """A partial chunk of the model's reasoning/thinking tokens.""" | |
| text: str | |
| class AgentThinkingComplete(ChatEvent): | |
| """The model has finished emitting thinking tokens for this turn.""" | |
| full_text: str | |
| class AgentStreamChunk(ChatEvent): | |
| """A partial chunk of the final text response.""" | |
| text: str | |
| class AgentComplete(ChatEvent): | |
| """The agent has finished the entire request loop.""" | |
| new_history: List[Any] = None # List[ModelMessage] | |