checkpoint
This commit is contained in:
parent
94f94cbebf
commit
d9f12ec0de
5 changed files with 63 additions and 6 deletions
13
vocode/user_implemented_agent/base_agent.py
Normal file
13
vocode/user_implemented_agent/base_agent.py
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
from fastapi import FastAPI, APIRouter
|
||||
import uvicorn
|
||||
|
||||
class BaseAgent():
|
||||
|
||||
def __init__(self):
|
||||
self.app = FastAPI()
|
||||
|
||||
async def respond(self, human_input) -> str:
|
||||
raise NotImplementedError
|
||||
|
||||
def run(self, host="localhost", port=3001):
|
||||
uvicorn.run(self.app, host=host, port=port)
|
||||
17
vocode/user_implemented_agent/restful_agent.py
Normal file
17
vocode/user_implemented_agent/restful_agent.py
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
from .base_agent import BaseAgent
|
||||
from pydantic import BaseModel
|
||||
from fastapi import APIRouter
|
||||
|
||||
class RESTfulAgent(BaseAgent):
|
||||
|
||||
class HumanInput(BaseModel):
|
||||
human_input: str
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.app.post("/respond")(self.respond_rest)
|
||||
|
||||
async def respond_rest(self, request: HumanInput):
|
||||
response = await self.respond(request.human_input)
|
||||
return {"response": response}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue