Spaces:
Sleeping
Sleeping
Update api_server.py
Browse files- api_server.py +4 -5
api_server.py
CHANGED
|
@@ -4,7 +4,7 @@ from fastapi import FastAPI, HTTPException, Depends
|
|
| 4 |
from fastapi.middleware.cors import CORSMiddleware
|
| 5 |
from pydantic import BaseModel
|
| 6 |
from backend.agent import run_agent
|
| 7 |
-
from typing import
|
| 8 |
|
| 9 |
|
| 10 |
app = FastAPI(title="Nursing Copilot API")
|
|
@@ -32,7 +32,7 @@ class PredictionRequest(BaseModel):
|
|
| 32 |
model: str | None = "gpt2-nursing"
|
| 33 |
|
| 34 |
class PredictionResponse(BaseModel):
|
| 35 |
-
completions:
|
| 36 |
|
| 37 |
# -----------------------------
|
| 38 |
# API Endpoint
|
|
@@ -42,11 +42,10 @@ def predict_completion(request: PredictionRequest):
|
|
| 42 |
|
| 43 |
input_text = request.prompt
|
| 44 |
|
| 45 |
-
# ⭐ 交給 agent(固定 or AI)
|
| 46 |
result = run_agent(input_text)
|
| 47 |
|
| 48 |
-
# ⭐
|
| 49 |
-
return {"completions": result}
|
| 50 |
|
| 51 |
|
| 52 |
# -----------------------------
|
|
|
|
| 4 |
from fastapi.middleware.cors import CORSMiddleware
|
| 5 |
from pydantic import BaseModel
|
| 6 |
from backend.agent import run_agent
|
| 7 |
+
from typing import List, Dict, Any
|
| 8 |
|
| 9 |
|
| 10 |
app = FastAPI(title="Nursing Copilot API")
|
|
|
|
| 32 |
model: str | None = "gpt2-nursing"
|
| 33 |
|
| 34 |
class PredictionResponse(BaseModel):
|
| 35 |
+
completions: List[Dict[str, Any]]
|
| 36 |
|
| 37 |
# -----------------------------
|
| 38 |
# API Endpoint
|
|
|
|
| 42 |
|
| 43 |
input_text = request.prompt
|
| 44 |
|
|
|
|
| 45 |
result = run_agent(input_text)
|
| 46 |
|
| 47 |
+
# ⭐ 無論 fixed 或 AI,都包成 list
|
| 48 |
+
return {"completions": [result]}
|
| 49 |
|
| 50 |
|
| 51 |
# -----------------------------
|