Skip to content

Latest commit

 

History

History
63 lines (45 loc) · 1.21 KB

File metadata and controls

63 lines (45 loc) · 1.21 KB

API 規格

Base URL:http://localhost:8000 Swagger UI:/docs

文件管理

POST /api/docs/upload

multipart/form-data

  • file: 檔案(PDF / MD / TXT / HTML)
  • tag: 自訂標籤(可選,例如 "manufacturing")

Response 200

{ "docId": "doc_a1b2c3", "title": "sop.pdf", "chunks": 42, "tag": "manufacturing" }

GET /api/docs

列出所有已上傳文件。

DELETE /api/docs/{docId}

刪除文件(含其向量索引)。


對話

POST /api/chat (Server-Sent Events)

{ "question": "錫膏印刷機的清潔週期是多久?", "top_k": 4, "tag": "manufacturing" }

回應為 SSE 事件流:

Event Data 用途
sources [{index, docId, title, chunkIndex, score}] 檢索到的來源
chunk {"text": "..."} LLM 回答的下一段文字
done {} 完成訊號

範例:

event: sources
data: [{"index":1,"docId":"doc_a1b2c3","title":"SOP","chunkIndex":7,"score":0.89}]

event: chunk
data: {"text":"根據 SOP,"}

event: chunk
data: {"text":"印刷機鋼板每 100 片清潔一次 [doc:1]。"}

event: done
data: {}

健康檢查

GET /healthz

{ "status": "ok" }