Skip to content

Commit

Permalink
update app versions and fix output device bug (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kian1354 authored May 19, 2023
1 parent d506757 commit b37bf7a
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 14 deletions.
2 changes: 1 addition & 1 deletion apps/client_backend/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
vocode==0.1.105
vocode==0.1.108
2 changes: 1 addition & 1 deletion apps/langchain_agent/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
vocode==0.1.105
vocode==0.1.108
redis
twilio
1 change: 0 additions & 1 deletion apps/langchain_agent/tools/vocode.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
2 changes: 1 addition & 1 deletion apps/telephony_app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion apps/telephony_app/outbound_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from speller_agent import SpellerAgentConfig

BASE_URL = os.getenv("BASE_URL")
BASE_URL = os.environ["BASE_URL"]

config_manager = RedisConfigManager()

Expand Down
2 changes: 1 addition & 1 deletion apps/telephony_app/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
vocode==0.1.105
vocode==0.1.108
redis
twilio
23 changes: 16 additions & 7 deletions apps/telephony_app/speller_agent.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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")
2 changes: 1 addition & 1 deletion vocode/streaming/output_device/twilio_output_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions vocode/streaming/output_device/websocket_output_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()

0 comments on commit b37bf7a

Please sign in to comment.