Update app.py
Browse files
app.py
CHANGED
|
@@ -3,14 +3,28 @@ from pydantic import BaseModel
|
|
| 3 |
|
| 4 |
app = FastAPI()
|
| 5 |
|
| 6 |
-
|
|
|
|
| 7 |
prompt: str
|
| 8 |
|
| 9 |
-
@app.post("/chat")
|
| 10 |
-
def chat(req: Request):
|
| 11 |
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
return {
|
| 15 |
-
"
|
| 16 |
}
|
|
|
|
| 3 |
|
| 4 |
app = FastAPI()
|
| 5 |
|
| 6 |
+
|
| 7 |
+
class ChatRequest(BaseModel):
|
| 8 |
prompt: str
|
| 9 |
|
|
|
|
|
|
|
| 10 |
|
| 11 |
+
@app.get("/")
|
| 12 |
+
def root():
|
| 13 |
+
return {
|
| 14 |
+
"status": "running",
|
| 15 |
+
"message": "Space is working"
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
|
| 19 |
+
@app.get("/health")
|
| 20 |
+
def health():
|
| 21 |
+
return {
|
| 22 |
+
"healthy": True
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
@app.post("/chat")
|
| 27 |
+
def chat(req: ChatRequest):
|
| 28 |
return {
|
| 29 |
+
"reply": f"You said: {req.prompt}"
|
| 30 |
}
|