File size: 565 Bytes
f94af79 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import uvicorn
import argparse
import random
from fastapi import FastAPI, Form
from fastapi.responses import Response
parser = argparse.ArgumentParser(description="Chat API")
parser.add_argument("--port", type=int, default=10024, help="Port")
args = parser.parse_args()
app = FastAPI()
@app.post("/chat")
async def chat_endpoint(text: str = Form(...)):
print("Input text:", text)
response = random.choice(["hello?", "hello world!"])
return Response(content=response)
if __name__ == '__main__':
uvicorn.run(app, host="0.0.0.0", port=args.port)
|