Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
CTI-RAG is a Retrieval-Augmented Generation (RAG) framework for Cyber Threat Intelligence (CTI), integrating knowledge graph and causal reasoning capabilities to provide security analysts with an intelligent threat intelligence analysis tool.
| Date | Stars |
|---|---|
| 2026-07-31 | 299 |
| 2026-08-05 | 299 |
| 2026-08-06 | 299 |
Today
— stars today
This week
— stars this week
This month
— stars this month
Momentum
0.0
growth rate 0.00%/day
# ThreatRAG
[](https://oosmetrics.com/repo/Ais1on/CTI-RAG)
ThreatRAG 是一个面向网络威胁情报(Cyber Threat Intelligence, CTI)的 RAG 系统。它不仅做文本问答,还把知识库检索、知识图谱、多模型路由、混合检索、会话管理和后台任务串成一套可部署的威胁情报分析后端。
项目目标是让安全分析师能够围绕攻击组织、恶意软件、漏洞、基础设施、攻击活动等实体进行可追溯的多跳分析,而不是只返回几段相似文本。
## 核心能力
### CTI RAG 问答
- 支持面向知识库的威胁情报问答。
- 支持文件上传、文本分块、向量化和相似度检索。
- 支持流式聊天接口,适合前端实时展示回答。
- 支持通过 `meta.db_id`、`meta.model_provider`、`meta.model_name` 等参数控制知识库和模型。
### 知识图谱
- 从 CTI 文本中抽取实体与关系,沉淀为可查询的图结构。
- 使用 Neo4j 存储威胁实体、关系和索引结果。
- 提供图谱索引器启动、停止、状态查询和立即执行接口。
- 支持文件实体抽取任务,适合把威胁报告批量转为图谱数据。
### 混合检索
- 结合向量检索、图谱查询、查询改写和 rerank 能力。
- 面向多跳问题时,可以把结构化关系和文本证据共同作为回答上下文。
- 适合回答“某攻击组织使用了哪些漏洞”“某 IP 周围两跳内有哪些威胁实体”这类关系型问题。
### 多模型路由
- 支持 OpenAI、DeepSeek、Ollama、SiliconFlow 等模型来源的接入配置。
- 支持默认模型、回退链、请求超时、流式超时和单模型重试次数。
- 支持模型熔断配置,便于在模型异常时降级到备用模型。
- 聊天响应会返回路由元数据,便于判断实际使用模型和是否发生降级。
### 多会话聊天
- 支持自动创建会话,也支持显式创建会话后继续对话。
- 会话与 `user_id` 绑定,便于做用户级隔离。
- 使用 MySQL 持久化会话和消息,使用 Redis 加速运行时读取。
- 提供会话列表、会话详情、更新会话、删除会话和删除消息接口。
### 后台任务
- 使用 RabbitMQ 投递后台任务。
- `threatrag-worker` 独立运行,适合处理异步任务和运行时健康检查。
- API 镜像和 worker 镜像分离,便于生产环境独立扩缩容。
## 系统架构
```mermaid
flowchart LR
Frontend["前端 / API Client"] --> API["ThreatRAG FastAPI"]
API --> MySQL["MySQL\n会话与知识库元数据"]
API --> Redis["Redis\n运行时缓存"]
API --> RabbitMQ["RabbitMQ\n任务队列"]
RabbitMQ --> Worker["threatrag-worker"]
API --> Milvus["Milvus\n向量检索"]
Milvus --> Etcd["Etcd"]
Milvus --> MinIO["MinIO"]
API --> Neo4j["Neo4j\n知识图谱"]
API --> Ollama["Ollama\n本地模型"]
API --> CloudModels["OpenAI / DeepSeek / SiliconFlow"]
```
当前 Docker Compose 部署包含:
| 服务 | 作用 | 默认端口 |
| --- | --- | --- |
| `threatrag` | FastAPI 后端 | `8006:8000` |
| `threatrag-worker` | 后台任务 worker | 无外部端口 |
| `mysql` | 会话与元数据存储 | `3309:3306` |
| `redis` | 缓存与运行时状态 | `6379:6379` |
| `rabbitmq` | 任务队列与管理后台 | `5672:5672`, `15672:15672` |
| `neo4j` | 知识图谱数据库 | `7475:7474`, `7688:7687` |
| `milvus-standalone` | 向量数据库 | `19530:19530`, `9091:9091` |
| `minio` | Milvus 对象存储依赖 | `9000:9000`, `9001:9001` |
| `etcd` | Milvus 元数据依赖 | 容器内访问 |
| `ollama` | 本地模型服务 | `11434:11434` |
## 仓库结构
```text
ThreatRAG/
├── rag/
│ ├── api/routers/ # FastAPI 路由:chat/data/graph/auth
│ ├── cache/ # Redis 会话与运行时缓存
│ ├── config/ # 运行时配置
│ ├── mq/ # RabbitMQ 发布者与 worker
│ └── vector/ # 向量数据库相关封装
├── packages/
│ ├── core/ # 检索、知识库、图谱、实体抽取、RL 推理
│ ├── manager/ # MySQL、Milvus、Neo4j、会话管理
│ ├── models/ # Chat model、embedding、rerank、model router
│ ├── plugins/ # OCR、OneKE 等插件能力
│ └── utils/ # Prompt、日志、BM25、Web search 等工具
├── docs/ # API、部署、模型和研发文档
├── tests/ # 单元测试和运行时 wiring 测试
├── models/ # 本地模型与推理权重目录
├── data/ # Docker Compose 本地持久化数据目录
├── Dockerfile # API 镜像
├── Dockerfile.worker # Worker 镜像
├── docker-compose.yml # 推荐部署入口
├── config.yaml # 应用功能开关与本地配置
├── main.py # FastAPI 本地启动入口
└── worker.py # Worker 本地启动入口
```
## 快速部署
推荐使用 Docker Compose 启动完整环境。这样会同时拉起 API、worker、MySQL、Redis、RabbitMQ、Neo4j、Milvus、MinIO、Etcd 和 Ollama。
### 1. 克隆仓库
```bash
git clone https://github.com/Ais1on/CTI-RAG.git
cd CTI-RAG
```
### 2. 创建 `.env`
在仓库根目录创建 `.env`,至少配置你要使用的模型密钥。
```dotenv
# 运行环境
FASTAPI_ENV=production
# 云端模型密钥,按需填写
OPENAI_API_KEY=
DEEPSEEK_API_KEY=
ZHIPUAI_API_KEY=
SILICONFLOW_API_KEY=
SILICONFLOW_API_BASE=https://api.siliconflow.cn/v1
# Neo4j
NEO4J_USERNAME=neo4j
NEO4J_PASSWORD=12345678
# 多模型路由
MODEL_ROUTER_ENABLED=true
MODEL_ROUTER_DEFAULT_PROVIDER=deepseek
MODEL_ROUTER_DEFAULT_MODEL=deepseek-chat
MODEL_ROUTER_FALLBACK_CHAIN=deepseek:deepseek-chat,ollama:qwen3:30b,ollama:qwen2.5:7b
MODEL_ROUTER_REQUEST_TIMEOUT_SECONDS=45
MODEL_ROUTER_STREAM_TIMEOUT_SECONDS=90
MODEL_ROUTER_MAX_RETRIES_PER_MODEL=1
# 模型熔断
MODEL_CIRCUIT_Excerpt of 9,426 characters
Read on GitHubWould you bet a product on this? Bounded 0–100 and slow moving.
matched fp:ee63f3bd09db2198, desc:retrieval-augmented generation, desc:retrieval augmented, desc:knowledge graph