Spaces:
Running
Running
Create fastAPI.py
Browse files- fastAPI.py +12 -0
fastAPI.py
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastapi import FastAPI
|
2 |
+
from pydantic import BaseModel
|
3 |
+
|
4 |
+
app = FastAPI()
|
5 |
+
|
6 |
+
class Prompt(BaseModel):
|
7 |
+
text: str
|
8 |
+
|
9 |
+
@app.post("/chat")
|
10 |
+
async def chat(prompt: Prompt):
|
11 |
+
response = generate_response(prompt.text)
|
12 |
+
return {"response": response}
|