並行雙派檢索
import asyncio, aiohttp
TERMS = ["三魂七魄", "五雷", "紫府"]
SECTS = ["正一", "全真"]
async def fetch(session, sect, term):
async with session.post(
"https://lius.cc/api/llm-rag",
json={"q": f"{sect} {term}", "n": 3, "types": ["scripture", "concept", "paper"]},
) as r:
r.raise_for_status()
payload = await r.json()
return sect, term, payload.get("hits", [])
async def main():
async with aiohttp.ClientSession() as s:
tasks = [fetch(s, sect, t) for t in TERMS for sect in SECTS]
results = await asyncio.gather(*tasks)
for sect, term, hits in results:
print(f"\n[{sect}] {term}")
for h in hits[:2]:
print(f" - {h['name']}")
# await main()
📜 本 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 索引