链载Ai

标题: 5.6K Star!R2R:一个支持RAG的AI检索系统 [打印本页]

作者: 链载Ai    时间: 昨天 12:54
标题: 5.6K Star!R2R:一个支持RAG的AI检索系统

R2R 简介

R2R[1](Reason to Retrieve)是一个先进的 AI 检索系统,支持检索增强生成(Retrieval-Augmented Generation,RAG)功能,并具备生产级特性。它基于 RESTful API 构建,提供多模态内容摄取、混合搜索、知识图谱以及全面的文档管理功能。

此外,R2R 还包含一个深度研究 API,能够从知识库和互联网中获取相关数据,为复杂查询提供更丰富、更具上下文感知能力的答案。

项目特点

主要特点

使用场景

R2R 可广泛应用于需要高效检索和知识管理的场景,例如:

项目使用

云服务选项

通过 SciPhi Cloud 使用 R2R,无需信用卡即可享受免费套餐,详细可参考快速开始[2]

自托管选项

pip install r2r
exportOPENAI_API_KEY=sk-...
python -m r2r.serve
gitclonegit@github.com:SciPhi-AI/R2R.git &&cdR2R
exportR2R_CONFIG_NAME=full OPENAI_API_KEY=sk-...
docker compose -f compose.full.yaml --profile postgres up -d

详细自托管指南请参考自托管文档[3]

使用 API

  1. 安装 SDK 并设置
pip install r2r
exportR2R_API_KEY=pk_..sk_... # Get from SciPhi Cloud dashboard
npm i r2r-js
exportR2R_API_KEY=pk_..sk_... # Get from SciPhi Cloud dashboard
  1. 客户端初始化
fromr2rimportR2RClient
client = R2RClient() # 如为自托管,请指定 base_url
const{ r2rClient } =require('r2r-js');
constclient =newr2rClient(); // 如为自托管,请指定 baseURL
  1. 文档操作
client.documents.create_sample(hi_res=True)
client.documents.list()
  1. 搜索与 RAG
results = client.retrieval.search(query="What is DeepSeek R1?")
response = client.retrieval.rag(query="What is DeepSeek R1?")
response = client.retrieval.agent(
message={"role":"user","content":"What does deepseek r1 imply? Think about market, societal implications, and more."},
rag_generation_config={
"model"="anthropic/claude-3-7-sonnet-20250219",
"extended_thinking":True,
"thinking_budget":4096,
"temperature":1,
"top_p":None,
"max_tokens_to_sample":16000,
},
mode="research"# 深度研究风格输出
)

参考文档







欢迎光临 链载Ai (https://www.lianzai.com/) Powered by Discuz! X3.5