傷寒論臨床決策輔助 WebUI (shanghanlun-assistant)
以《傷寒論》六經辨證為骨架的臨床決策支援 WebUI:八綱快診 → 六經定位 → LLM 追問 → 方證推論 → 醫囑選方 → 服藥觀察 → 加減/救逆。
功能(v0.6.1)
- 雙診模式:⚡ 快診(主訴 LLM 抽取 + 八綱 4 題)/ 📋 詳診(望聞問切 8 步)
- 推論引擎:症狀×六經權重矩陣 + 互斥組 + 鑑別問答 + 病人 modifier(孕/老/小/病史×方證禁忌)+ 救逆標籤
- LLM 整合(本地 llama.cpp,全部安全降級):主訴症狀抽取、依主訴動態追問(含加減項生成題)、方證 rerank、選方後 RAG×LLM 加減項建議、舌診照片 VLM
- 七典 RAG:金匱要略/溫病條辨/備急千金要方/景岳全書/萬病回春/醫宗金鑑/醫林改錯,9,452 chunks + jina embeddings,推論頁「典籍出處」+ Library 跨典檢索
- Library:傷寒論 398 條 × 4 版本對照(宋本/張卿子/來蘇集/桂林古本)全文搜尋
- UI 素材:59 張 MOSS-Image-SFT 生成(icon/教學插圖/海報),詳見
v2_moss_p0/REPORT.md - SQLite server-side session(非 cookie)、多語系 zh/en/ja、Flask SubpathMiddleware(Tailscale Funnel
/shanghanlun/)
執行
pip install shanghanlun-assistant # 或 clone 後: cd webui && pip install flask
python3 -m webui.app # :8501, http://localhost:8501/shanghanlun/
LLM 端點(可選,無則規則引擎獨立運作):llama.cpp :8080(主模型)、:8085 thinking-off proxy、:8082 jina embeddings。
RAG 語料重建:corpus/build_rag.py(需先 clone TCM-Ancient-Books,見 script 內說明)。
RAG 語料(可選)
語料檔(246MB 古籍 clone + embedding 向量)不入 git,由腳本重建:
pip install -r requirements.txt # numpy + opencc 一併裝
./corpus/setup_rag.sh # clone 古籍庫 → 切塊繁化 → embedding
不建置也能正常使用——RAG 相關面板自動隱藏,其餘功能不受影響。
Embedding 後端選擇(本機或雲端)
到 webui 的「⚙ 設定」頁可切換:
- 本機
:8082(預設):llama.cpp 跑jina-embeddings-v5-small-retrieval-Q8_0,免金鑰、免費 - Jina AI 雲端(建議給沒有本機 embedding server 的部署):
建議模型
jina-embeddings-v5-small-retrieval(與本機同款)。 申請方式:- 到 jina.ai → 右上 Sign up(Google / GitHub 登入即可,免信用卡)
- 到 jina.ai/api-key 點 Create API Key,複製
jina_xxxx... - 貼進「⚙ 設定 → Embedding 後端 → Jina API Key」儲存 免費額度對建置整個七典語料(約 150 萬 tokens)綽綽有餘。
- 自訂:任何 OpenAI 相容
/v1/embeddings端點
建置腳本 corpus/build_rag.py 會自動讀 webui 設定頁的 embedding 設定,也可用環境變數覆蓋:EMBED_URL / EMBED_MODEL / EMBED_KEY。
授權
Apache-2.0(見 LICENSE)。UI 素材由 MOSS-Image-SFT 生成(該模型 Apache-2.0)。 七典文本來源:TCM-Ancient-Books(古籍公有領域)。
Metadata
Release files for shanghanlun-assistant 0.6.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| shanghanlun_assistant-0.6.2.tar.gz | 6.7 MB | With provenance | Details for shanghanlun_assistant-0.6.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| shanghanlun_assistant-0.6.2-py3-none-any.whl | Python 3 | none | any | Details for shanghanlun_assistant-0.6.2-py3-none-any.whl |
Total release size: 13.5 MB
Release files / shanghanlun_assistant-0.6.2.tar.gz
| Download URL | shanghanlun_assistant-0.6.2.tar.gz |
|---|---|
| Size | 6.7 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
240b2040d9fc55592aa51689a9a170a6cf7fc181fe385bb8e85711b011514f89
|
|
BLAKE2b-256 checksum How to use checksums |
0963b926cdc9bd875327e9d390d51f33e9aaa26806c66d83800722aea1af540b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.
Transparency logRelease files / shanghanlun_assistant-0.6.2-py3-none-any.whl
| Download URL | shanghanlun_assistant-0.6.2-py3-none-any.whl |
|---|---|
| Size | 6.8 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
58c94cad3992d7cdafc79ad89c4b1d4897d60558807a4cfa2197ea0728319b66
|
|
BLAKE2b-256 checksum How to use checksums |
02a4633296ced88fd18d613ea8495f13cded47519dcd4e4299d3014193f00d7e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.
Transparency logSecurity for shanghanlun-assistant 0.6.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for shanghanlun_assistant-0.6.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.