Download src/open_llm_vtuber/agent/agents/agent_interface.py from britto224/test_ui: direct link, hf CLI and curl.
- Browser
- Download file 1.83 kB
-
https://huggingface.co/spaces/britto224/test_ui/resolve/main/src/open_llm_vtuber/agent/agents/agent_interface.py
- Command line
-
hf download hf://spaces/britto224/test_ui/src/open_llm_vtuber/agent/agents/agent_interface.py
-
curl -L -o agent_interface.py https://huggingface.co/spaces/britto224/test_ui/resolve/main/src/open_llm_vtuber/agent/agents/agent_interface.py
1.83 kB
| from abc import ABC, abstractmethod | |
| from typing import AsyncIterator | |
| from loguru import logger | |
| from ..output_types import BaseOutput | |
| from ..input_types import BaseInput | |
| class AgentInterface(ABC): | |
| """Base interface for all agent implementations""" | |
| async def chat(self, input_data: BaseInput) -> AsyncIterator[BaseOutput]: | |
| """ | |
| Chat with the agent asynchronously. | |
| This function should be implemented by the agent. | |
| Output type depends on the agent's output_type: | |
| - SentenceOutput: For text-based responses with display and TTS text | |
| - AudioOutput: For direct audio output with display text and transcript | |
| Args: | |
| input_data: BaseInput - User input data | |
| Returns: | |
| AsyncIterator[BaseOutput] - Stream of agent outputs | |
| """ | |
| logger.critical("Agent: No chat function set.") | |
| raise ValueError("Agent: No chat function set.") | |
| def handle_interrupt(self, heard_response: str) -> None: | |
| """ | |
| Handle user interruption. This function will be called when the agent is interrupted. | |
| Args: | |
| heard_response: str - The part of response heard before interruption | |
| """ | |
| logger.warning( | |
| """Agent: No interrupt handler set. The agent may not handle interruptions | |
| correctly. The AI may not be able to understand that it was interrupted.""" | |
| ) | |
| pass | |
| def set_memory_from_history(self, conf_uid: str, history_uid: str) -> None: | |
| """ | |
| Load the agent's working memory from chat history | |
| Args: | |
| conf_uid: str - Configuration ID | |
| history_uid: str - History ID | |
| """ | |
| pass | |