checkpoint

This commit is contained in:
Ajay Raj 2023-03-01 14:50:30 -08:00
commit d9f12ec0de
5 changed files with 63 additions and 6 deletions

View 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)

View 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}