MarcoLeung052 commited on
Commit
89e304b
·
verified ·
1 Parent(s): 421fc88

Update api_server.py

Browse files
Files changed (1) hide show
  1. 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 Union
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: list[dict]
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
- # ⭐ agent 統一回傳 list
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
  # -----------------------------