僑委會問答 API 文檔

GET /health

健康檢查端點

範例:
curl http://localhost:8000/health

GET /cache/status

獲取提示快取狀態

範例:
curl http://localhost:8000/cache/status

POST /cache/update

強制更新提示快取(從 Google Doc 重新載入)

範例:
curl -X POST http://localhost:8000/cache/update

GET /cache/content

獲取快取內容預覽(前 500 字元)

範例:
curl http://localhost:8000/cache/content

GET /download/keywords

下載關鍵字搜尋結果檔案 (keyword.txt)

參數: 範例:
curl "http://localhost:8000/download/keywords?keywords=僑委會,日本,華商總會" -o keywords.txt
curl "http://localhost:8000/download/keywords?keywords=泰國,中國華文學校,華文教育團體" -o keywords.txt

注意: 系統會根據關鍵字自動生成對應的檔案供下載

GET /query

通過 URL 參數查詢問題

參數: 範例:
curl "http://localhost:8000/query?q=請問僑委會對於友我「日本華商總會」歷年來辦理活動置入中國元素之掌握?"

POST /query

通過 JSON 請求體查詢問題

請求體格式:
{
  "question": "您的問題",
  "user": "用戶識別",
  "model": "meta-llama/llama-4-maverick",
  "topk": 10,
  "provider": "openrouter",
  "additionalPrompt": "請特別注意時間順序"
}
範例:
curl -X POST http://localhost:8000/query \
  -H "Content-Type: application/json" \
  -d '{"question": "請問僑委會對於友我「日本華商總會」歷年來辦理活動置入中國元素之掌握?"}'

回應格式

{
  "question": "使用者問題",
  "answer": "生成的答案",
  "metadata": {
    "processingTime": {
      "total": 1234.56,
      "keywords": 123.45,
      "search": 234.56,
      "answer": 876.55
    },
    "keywords": ["關鍵字1", "關鍵字2"],
    "resultsCount": 10,
    "confidence": 85,
    "timestamp": "2024-01-01T12:00:00.000Z"
  }
}