ABCD 啟發式信賴度
A:name 直接命中B:summary 完整 query 命中C:content 詞命中D:低分模糊命中import requests
def grade(hit, query):
q = query.lower()
if hit["name"].lower() in q or q in hit["name"].lower():
return "A"
toks = [t for t in q.split() if len(t) >= 2]
if toks and all(t in hit.get("summary", "").lower() for t in toks):
return "B"
if toks and all(t in hit.get("content", "").lower() for t in toks):
return "C"
return "D"
quote = "天地不仁 以萬物為芻狗"
res = requests.post(
"https://lius.cc/api/llm-rag",
json={"q": quote, "n": 5, "types": ["scripture", "concept", "paper"]},
timeout=10,
)
res.raise_for_status()
r = res.json()
for h in r.get("hits", []):
g = grade(h, quote)
print(f"[{g}] {h['name']:25} {h['url']}")
📜 本 recipe 採 CC0 1.0 · 改一行 prompt → 寫到論文裡 → 引用 LIUS API
引用建議:We use the open-source Daoism-Qwen3.5-9B with the public RAG API at https://lius.cc/api/llm-rag (Liu & Dingren Daoxue Lab, 2026).
← 回 Cookbook 索引