vocode-python/vocode/user_implemented_agent/restful_agent.py
2023-03-02 13:15:36 -08:00

15 lines
503 B
Python

from .base_agent import BaseAgent
from ..models.agent import RESTfulAgentInput, RESTfulAgentOutput
from pydantic import BaseModel
from fastapi import APIRouter
class RESTfulAgent(BaseAgent):
def __init__(self):
super().__init__()
self.app.post("/respond")(self.respond_rest)
async def respond_rest(self, request: RESTfulAgentInput) -> RESTfulAgentOutput:
response = await self.respond(request.human_input)
return RESTfulAgentOutput(response=response)