Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,21 @@ PUBMED_EMAIL=your_email@example.com
# Use a faster/cheaper model for Judge and Scheduling agents (~30–40% faster overall)
# If unset, LLM_MODEL is used for all agents.
# FAST_LLM_MODEL=gpt-3.5-turbo

# ── Hypertension RAG Service ─────────────────────────────────────────────────
# Base URL of the hypertensiondb FastAPI service (see ../hypertension/).
# Must be running before Acquire stage executes. Start it with:
# cd hypertension && hdb serve run --port 8000
HYPERTENSION_API_URL=http://localhost:8000

# HTTP timeout per /search request, in seconds
HYPERTENSION_API_TIMEOUT=10

# Number of chunks to request from /search (client aggregates into max_papers papers)
RAG_SEARCH_TOP_K=15

# Max papers to surface to downstream agents (after aggregation by evidence_id)
RAG_MAX_PAPERS=6

# Max supporting passages to keep per paper
RAG_MAX_PASSAGES_PER_PAPER=3
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@ logs/
.claude/
gemini文本生图.py
nul
.worktrees/

# hypertension/ is a separate git repository (its own .git/);
# kept alongside ebm5a as a sibling sub-project, not as a submodule.
hypertension/
28 changes: 13 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[![Python](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![OpenAI Compatible](https://img.shields.io/badge/API-OpenAI%20Compatible-412991.svg)](https://platform.openai.com/)
[![PubMed](https://img.shields.io/badge/data-PubMed%20实时检索-326599.svg)](https://pubmed.ncbi.nlm.nih.gov/)
[![RAG](https://img.shields.io/badge/data-Hypertension%20RAG-326599.svg)](https://github.com/FreedomIntelligence/TrueTruth)

</div>

Expand All @@ -29,13 +29,13 @@ TrueTruth将一段普通的临床问题文本全自动转化为**经过分级的

| 特性 | 说明 |
|------|------|
| **5A 工作流** | Ask(PICO 结构化)→ Acquire(PubMed 实时检索)→ Appraise(GRADE 评价)→ Apply(生成推荐)→ Assess(质量审查) |
| **5A 工作流** | Ask(PICO 结构化)→ Acquire(RAG 检索)→ Appraise(GRADE 评价)→ Apply(生成推荐)→ Assess(质量审查) |
| **GRADE 确定性计算** | LLM 输出分类标签,Python 代码确定性地计算 GRADE 等级,不依赖 LLM 对评级规则的理解 |
| **五种问题类型** | Therapy / Diagnosis / Prognosis / Harm / Prevention,每种类型触发不同 PubMed 检索过滤器 |
| **五种问题类型** | Therapy / Diagnosis / Prognosis / Harm / Prevention,每种类型触发不同检索策略 |
| **四级推荐强度** | Strong、Conditional(间接证据)、Consensus-based(指南/专家共识)、Insufficient Evidence |
| **实时文献检索** | 三层 PubMed 查询策略(严格→中等→宽松),24 小时磁盘缓存,MedCPT Listwise 重排序 |
| **Hypertension RAG** | 基于高血压领域 landmark trial 的向量检索服务,提供结构化证据块与 passage 级引用 |
| **鲁棒 JSON 解析** | 每个 Agent 与 Judge LLM 内置三阶段 JSON 恢复,LLM 输出格式错误不会导致工作流崩溃 |
| **完整审计追踪** | 每阶段评分(0–1)、问题清单、回退事件、调度决策全部记录,每条引用附带真实 PMID |
| **完整审计追踪** | 每阶段评分(0–1)、问题清单、回退事件、调度决策全部记录,每条引用附带真实来源 |
| **OpenAI 兼容** | 支持任何 OpenAI 兼容 API;Judge/Scheduling 可配置独立的快速模型以降低成本 |

### 工作流程
Expand Down Expand Up @@ -66,15 +66,15 @@ TrueTruth将一段普通的临床问题文本全自动转化为**经过分级的

- Python **3.10+**
- 兼容 OpenAI 的 API Key(OpenAI、Azure OpenAI 或其他兼容服务商)
- 免费的 PubMed 注册邮箱([NCBI API 使用规范](https://www.ncbi.nlm.nih.gov/home/about/policies/)要求
- Hypertension RAG 服务(见下方说明
- Docker + Docker Compose(仅 Docker 部署方式需要)

### 方式一:Docker(推荐)

```bash
git clone https://github.com/FreedomIntelligence/TrueTruth.git
cd TrueTruth
cp .env.example .env # 填写 LLM_API_KEY、LLM_BASE_URL、LLM_MODEL、PUBMED_EMAIL
cp .env.example .env # 填写 LLM_API_KEY、LLM_BASE_URL、LLM_MODEL
make check-env # 验证配置(可选但推荐)
make docker-up # 构建镜像并启动,首次约需 3–5 分钟
# 浏览器打开 http://localhost:8080
Expand All @@ -100,7 +100,9 @@ make cli QUERY="68岁男性,NSTEMI合并急性消化道出血,DAPT还是氯
LLM_BASE_URL=xxx
LLM_API_KEY=sk-...
LLM_MODEL=xxx
PUBMED_EMAIL=your_email@example.com

# Hypertension RAG 服务地址(默认本地 8000 端口)
HYPERTENSION_API_URL=http://localhost:8000

# 可选——Judge/Scheduling 使用更快的轻量模型,可节省约 30–40% 耗时
# FAST_LLM_MODEL=gpt-4o-mini
Expand Down Expand Up @@ -130,7 +132,7 @@ ebm5a/
│ ├── agents/
│ │ ├── base.py # 共享三阶段 JSON 恢复
│ │ ├── ask_agent.py # PICO 结构化 + 问题类型识别
│ │ ├── acquire_agent.py # PubMed 检索 + MedCPT 重排序
│ │ ├── acquire_agent.py # Hypertension RAG 检索
│ │ ├── appraise_agent.py # GRADE 评价(并行批次)
│ │ ├── apply_agent.py # 推荐综合生成
│ │ └── assess_agent.py # 推理链质量审查
Expand All @@ -144,9 +146,8 @@ ebm5a/
│ ├── state/
│ │ └── schema.py # 状态数据结构(dataclass + TypedDict)
│ ├── tools/
│ │ ├── pubmed_api.py # PubMed 客户端 + 24h 磁盘缓存
│ │ ├── medcpt.py # MedCPT Listwise 重排序
│ │ └── local_evidence_db.py # 本地向量数据库检索
│ │ ├── hypertension_rag_client.py # Hypertension RAG HTTP 客户端
│ │ └── medcpt.py # MedCPT 重排序(可选)
│ └── config/
│ ├── llm_config.py # get_llm() / get_fast_llm()
│ ├── prompts/ # 各 Agent 与 Judge 提示词(.txt)
Expand All @@ -168,7 +169,6 @@ ebm5a/
│ └── check_env.py # 配置验证脚本(make check-env)
├── tests/ # 测试目录
├── docs/ # 设计文档与故障排查
├── data/cache/ # PubMed 查询缓存(自动生成)
├── logs/ # 运行日志(自动生成)
├── Dockerfile.backend
├── Dockerfile.frontend
Expand Down Expand Up @@ -259,7 +259,5 @@ MIT © Winda0001 — 详见 [LICENSE](LICENSE)

## 致谢

- [NCBI PubMed](https://pubmed.ncbi.nlm.nih.gov/) — 实时生物医学文献数据库
- [MedCPT](https://github.com/ncbi/MedCPT) — NCBI 开发的生物医学密集检索与重排序模型
- [LangChain](https://python.langchain.com/) / [LangGraph](https://langchain-ai.github.io/langgraph/) — 智能体编排框架
- [GRADE Working Group](https://www.gradeworkinggroup.org/) — 证据分级方法论
Loading
Loading