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)