monster commit

This commit is contained in:
Ajay Raj 2023-03-03 18:24:56 -08:00
commit de6d76c955
14 changed files with 155 additions and 66 deletions

View file

@ -1,12 +1,27 @@
from vocode.user_implemented_agent.restful_agent import RESTfulAgent
from vocode.models.agent import RESTfulAgentOutput, RESTfulAgentText, RESTfulAgentEnd, WebSocketAgentMessage, WebSocketAgentTextMessage, WebSocketAgentStopMessage
from vocode.user_implemented_agent.websocket_agent import WebSocketAgent
class EchoAgent(WebSocketAgent):
class TestRESTfulAgent(RESTfulAgent):
async def respond(self, input: str) -> str:
async def respond(self, input: str) -> RESTfulAgentOutput:
print(input)
return ''.join(i + j for i, j in zip(input, ' ' * len(input)))
if "bye" in input:
return RESTfulAgentEnd()
else:
spelt = ''.join(i + j for i, j in zip(input, ' ' * len(input)))
return RESTfulAgentText(response=spelt)
class TestWebSocketAgent(WebSocketAgent):
async def respond(self, input: str) -> WebSocketAgentMessage:
print(input)
if "bye" in input:
return WebSocketAgentStopMessage()
else:
spelt = ''.join(i + j for i, j in zip(input, ' ' * len(input)))
return WebSocketAgentTextMessage.from_text(spelt)
if __name__ == "__main__":
agent = EchoAgent()
agent.run()
agent = TestWebSocketAgent()
agent.run(port=3001)