diff --git a/apps/client_backend/requirements.txt b/apps/client_backend/requirements.txt index bd241a3af..73e080592 100644 --- a/apps/client_backend/requirements.txt +++ b/apps/client_backend/requirements.txt @@ -1 +1 @@ -vocode==0.1.105 \ No newline at end of file +vocode==0.1.108 \ No newline at end of file diff --git a/apps/langchain_agent/requirements.txt b/apps/langchain_agent/requirements.txt index 220e56735..3cb2883c9 100644 --- a/apps/langchain_agent/requirements.txt +++ b/apps/langchain_agent/requirements.txt @@ -1,3 +1,3 @@ -vocode==0.1.105 +vocode==0.1.108 redis twilio \ No newline at end of file diff --git a/apps/langchain_agent/tools/vocode.py b/apps/langchain_agent/tools/vocode.py index 927019d87..4c401f263 100644 --- a/apps/langchain_agent/tools/vocode.py +++ b/apps/langchain_agent/tools/vocode.py @@ -33,7 +33,6 @@ def call_phone_number(input: str) -> str: config_manager=RedisConfigManager(), agent_config=ChatGPTAgentConfig( prompt_preamble=prompt, - end_conversation_on_goodbye=True, initial_message=BaseMessage(text=initial_message), ), logger=logging.Logger("call_phone_number"), diff --git a/apps/telephony_app/main.py b/apps/telephony_app/main.py index 29fc52be5..5933e36d5 100644 --- a/apps/telephony_app/main.py +++ b/apps/telephony_app/main.py @@ -19,7 +19,7 @@ config_manager = RedisConfigManager() -BASE_URL = os.getenv("BASE_URL") +BASE_URL = os.environ["BASE_URL"] telephony_server = TelephonyServer( base_url=BASE_URL, diff --git a/apps/telephony_app/outbound_call.py b/apps/telephony_app/outbound_call.py index 3ea9e0639..ecb6adbc7 100644 --- a/apps/telephony_app/outbound_call.py +++ b/apps/telephony_app/outbound_call.py @@ -10,7 +10,7 @@ from speller_agent import SpellerAgentConfig -BASE_URL = os.getenv("BASE_URL") +BASE_URL = os.environ["BASE_URL"] config_manager = RedisConfigManager() diff --git a/apps/telephony_app/requirements.txt b/apps/telephony_app/requirements.txt index 220e56735..3cb2883c9 100644 --- a/apps/telephony_app/requirements.txt +++ b/apps/telephony_app/requirements.txt @@ -1,3 +1,3 @@ -vocode==0.1.105 +vocode==0.1.108 redis twilio \ No newline at end of file diff --git a/apps/telephony_app/speller_agent.py b/apps/telephony_app/speller_agent.py index a30634be7..15ba44972 100644 --- a/apps/telephony_app/speller_agent.py +++ b/apps/telephony_app/speller_agent.py @@ -1,6 +1,8 @@ +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 +from vocode.streaming.models.agent import AgentConfig, AgentType, ChatGPTAgentConfig from vocode.streaming.agent.base_agent import BaseAgent from vocode.streaming.agent.factory import AgentFactory @@ -9,22 +11,29 @@ class SpellerAgentConfig(AgentConfig, type="agent_speller"): pass -class SpellerAgent(BaseAgent): +class SpellerAgent(BaseAgent[SpellerAgentConfig]): def __init__(self, agent_config: SpellerAgentConfig): super().__init__(agent_config=agent_config) - def respond( + async def respond( self, human_input, + conversation_id: str, is_interrupt: bool = False, - conversation_id: Optional[str] = None, ) -> Tuple[Optional[str], bool]: return "".join(c + " " for c in human_input), False class SpellerAgentFactory(AgentFactory): - def create_agent(self, agent_config: AgentConfig) -> BaseAgent: + def create_agent( + self, agent_config: AgentConfig, logger: Optional[logging.Logger] = None + ) -> BaseAgent: if agent_config.type == AgentType.CHAT_GPT: - return ChatGPTAgent(agent_config=agent_config) + return ChatGPTAgent( + agent_config=typing.cast(ChatGPTAgentConfig, agent_config) + ) elif agent_config.type == "agent_speller": - return SpellerAgent(agent_config=agent_config) + return SpellerAgent( + agent_config=typing.cast(SpellerAgentConfig, agent_config) + ) + raise Exception("Invalid agent config") diff --git a/vocode/streaming/output_device/twilio_output_device.py b/vocode/streaming/output_device/twilio_output_device.py index 9c639d0fd..1dcbc767d 100644 --- a/vocode/streaming/output_device/twilio_output_device.py +++ b/vocode/streaming/output_device/twilio_output_device.py @@ -23,9 +23,9 @@ def __init__( ) self.ws = ws self.stream_sid = stream_sid + self.active = True self.queue: asyncio.Queue[str] = asyncio.Queue() self.process_task = asyncio.create_task(self.process()) - self.active = True async def process(self): while self.active: diff --git a/vocode/streaming/output_device/websocket_output_device.py b/vocode/streaming/output_device/websocket_output_device.py index 1fa048ce8..d8b884c7c 100644 --- a/vocode/streaming/output_device/websocket_output_device.py +++ b/vocode/streaming/output_device/websocket_output_device.py @@ -15,6 +15,7 @@ def __init__( self.ws = ws self.active = True self.queue: asyncio.Queue[str] = asyncio.Queue() + self.process_task = asyncio.create_task(self.process()) def mark_closed(self): self.active = False @@ -28,3 +29,6 @@ def send_nonblocking(self, chunk: bytes): if self.active: audio_message = AudioMessage.from_bytes(chunk) self.queue.put_nowait(audio_message.json()) + + def terminate(self): + self.process_task.cancel()