update example + add chatgpt configs

This commit is contained in:
Ajay Raj 2023-03-03 10:42:45 -08:00
commit 477ea8407e
3 changed files with 15 additions and 6 deletions

View file

@ -5,7 +5,7 @@ import signal
from vocode.conversation import Conversation from vocode.conversation import Conversation
from vocode.helpers import create_microphone_input_and_speaker_output from vocode.helpers import create_microphone_input_and_speaker_output
from vocode.models.transcriber import DeepgramTranscriberConfig from vocode.models.transcriber import DeepgramTranscriberConfig
from vocode.models.agent import ChatGPTAgentConfig, RESTfulUserImplementedAgentConfig, WebSocketUserImplementedAgentConfig, EchoAgentConfig from vocode.models.agent import ChatGPTAgentConfig, RESTfulUserImplementedAgentConfig, WebSocketUserImplementedAgentConfig, EchoAgentConfig, ChatGPTAlphaAgentConfig, ChatGPTAgentConfig
from vocode.models.synthesizer import AzureSynthesizerConfig from vocode.models.synthesizer import AzureSynthesizerConfig
from vocode.user_implemented_agent.restful_agent import RESTfulAgent from vocode.user_implemented_agent.restful_agent import RESTfulAgent
@ -14,15 +14,17 @@ logging.root.setLevel(logging.INFO)
if __name__ == "__main__": if __name__ == "__main__":
microphone_input, speaker_output = create_microphone_input_and_speaker_output(use_default_devices=True) microphone_input, speaker_output = create_microphone_input_and_speaker_output(use_default_devices=False)
conversation = Conversation( conversation = Conversation(
input_device=microphone_input, input_device=microphone_input,
output_device=speaker_output, output_device=speaker_output,
transcriber_config=DeepgramTranscriberConfig.from_input_device(microphone_input), transcriber_config=DeepgramTranscriberConfig.from_input_device(microphone_input),
agent_config=EchoAgentConfig( agent_config=WebSocketUserImplementedAgentConfig(
initial_message="Hello!", initial_message="Hello!",
generate_responses=False, respond=WebSocketUserImplementedAgentConfig.RouteConfig(
url="wss://a8ea877c9548.ngrok.io/respond"
)
), ),
synthesizer_config=AzureSynthesizerConfig.from_output_device(speaker_output) synthesizer_config=AzureSynthesizerConfig.from_output_device(speaker_output)
) )

View file

@ -4,7 +4,8 @@ from vocode.user_implemented_agent.websocket_agent import WebSocketAgent
class EchoAgent(WebSocketAgent): class EchoAgent(WebSocketAgent):
async def respond(self, input: str) -> str: async def respond(self, input: str) -> str:
return input print(input)
return ''.join(i + j for i, j in zip(input, ' ' * len(input)))
if __name__ == "__main__": if __name__ == "__main__":
agent = EchoAgent() agent = EchoAgent()

View file

@ -6,6 +6,7 @@ from .model import TypedModel, BaseModel
class AgentType(str, Enum): class AgentType(str, Enum):
BASE = "base" BASE = "base"
LLM = "llm" LLM = "llm"
CHAT_GPT_ALPHA = "chat_gpt_alpha"
CHAT_GPT = "chat_gpt" CHAT_GPT = "chat_gpt"
ECHO = "echo" ECHO = "echo"
INFORMATION_RETRIEVAL = "information_retrieval" INFORMATION_RETRIEVAL = "information_retrieval"
@ -21,9 +22,14 @@ class LLMAgentConfig(AgentConfig, type=AgentType.LLM):
prompt_preamble: str prompt_preamble: str
expected_first_prompt: Optional[str] = None expected_first_prompt: Optional[str] = None
class ChatGPTAlphaAgentConfig(AgentConfig, type=AgentType.CHAT_GPT_ALPHA):
prompt_preamble: str
expected_first_prompt: Optional[str] = None
class ChatGPTAgentConfig(AgentConfig, type=AgentType.CHAT_GPT): class ChatGPTAgentConfig(AgentConfig, type=AgentType.CHAT_GPT):
prompt_preamble: str prompt_preamble: str
expected_first_prompt: Optional[str] = None expected_first_prompt: Optional[str] = None
generate_responses: bool = False
class InformationRetrievalAgentConfig( class InformationRetrievalAgentConfig(
AgentConfig, type=AgentType.INFORMATION_RETRIEVAL AgentConfig, type=AgentType.INFORMATION_RETRIEVAL
@ -90,4 +96,4 @@ class AgentReadyMessage(WebSocketAgentMessage, type=WebSocketAgentMessageType.AG
pass pass
class AgentStopMessage(WebSocketAgentMessage, type=WebSocketAgentMessageType.AGENT_STOP): class AgentStopMessage(WebSocketAgentMessage, type=WebSocketAgentMessageType.AGENT_STOP):
pass pass