lordsnow21 commited on
Commit
c8f4eef
·
verified ·
1 Parent(s): c859ce0

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ from fastapi.middleware.cors import CORSMiddleware
3
+ from pydantic import BaseModel
4
+ from model import generate_response
5
+
6
+ app = FastAPI()
7
+
8
+ app.add_middleware(
9
+ CORSMiddleware,
10
+ allow_origins=["*"],
11
+ allow_credentials=False,
12
+ allow_methods=["*"],
13
+ allow_headers=["*"],
14
+ )
15
+
16
+ class ChatRequest(BaseModel):
17
+ message: str
18
+ history: list[str] = []
19
+
20
+ @app.get("/")
21
+ def health():
22
+ return {"status": "ok"}
23
+
24
+ @app.post("/chat")
25
+ def chat(req: ChatRequest):
26
+ reply = generate_response(req.message)
27
+ return {"reply": reply}