From a4002ba58668d3dcad35552f7bd0bb39ab4fa6be Mon Sep 17 00:00:00 2001 From: Evan Zachary Date: Sun, 11 Feb 2024 07:51:22 -0700 Subject: ppppp --- telephony_app/speller_agent.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 telephony_app/speller_agent.py (limited to 'telephony_app/speller_agent.py') diff --git a/telephony_app/speller_agent.py b/telephony_app/speller_agent.py new file mode 100644 index 0000000..3782663 --- /dev/null +++ b/telephony_app/speller_agent.py @@ -0,0 +1,39 @@ +import logging +from typing import Optional, Tuple +import typing +from vocode.streaming.agent.chat_gpt_agent import ChatGPTAgent +from vocode.streaming.models.agent import AgentConfig, AgentType, ChatGPTAgentConfig +from vocode.streaming.agent.base_agent import BaseAgent, RespondAgent +from vocode.streaming.agent.factory import AgentFactory + + +class SpellerAgentConfig(AgentConfig, type="agent_speller"): + pass + + +class SpellerAgent(RespondAgent[SpellerAgentConfig]): + def __init__(self, agent_config: SpellerAgentConfig): + super().__init__(agent_config=agent_config) + + async def respond( + self, + human_input, + conversation_id: str, + is_interrupt: bool = False, + ) -> Tuple[Optional[str], bool]: + return "".join(c + " " for c in human_input), False + + +class SpellerAgentFactory(AgentFactory): + def create_agent( + self, agent_config: AgentConfig, logger: Optional[logging.Logger] = None + ) -> BaseAgent: + if agent_config.type == AgentType.CHAT_GPT: + return ChatGPTAgent( + agent_config=typing.cast(ChatGPTAgentConfig, agent_config) + ) + elif agent_config.type == "agent_speller": + return SpellerAgent( + agent_config=typing.cast(SpellerAgentConfig, agent_config) + ) + raise Exception("Invalid agent config") -- cgit v1.2.3