Quivr(quivr-core):面向开发者的「开箱即用」RAG 核心库,让 GenAI 快速接入你的应用
Quivr 是 The Vibe Company(原 QuivrHQ)开源项目 quivr-core 的仓库主页,提供一个「有主见」的 RAG(检索增强生成)实现:目标是让开发者不必自己搭 RAG,而是把精力放在产品本身。它可接入任意 LLM(OpenAI、Anthropic、Mistral、Gemma 等,并支持 Ollama 本地模型),支持 PDF、TXT、Markdown 等任意文件并可自定义解析器,允许定制检索流程、加入联网搜索与工具,并可与 Megaparse 配合完成文件摄入。项目以 Apache 2.0 许可证发布,要求 Python 3.10 或更高版本,核心安装命令为 pip install quivr-core,官方称 5 行代码即可创建 Brain 并提问。
社区作者 · zZz
它解决什么问题
Quivr 的定位是「你的第二大脑,由生成式 AI 赋能」,仓库主体是 Quivr 的核心(quivr-core),也是 Quivr.com 的「大脑」。
【核心特性】
- 有主见的 RAG(Opiniated RAG):官方自述其 RAG 实现「有主见、快速且高效」,让开发者专注产品。
- 任意 LLM:Quivr 可与任何 LLM 配合使用,来源明确列举 OpenAI、Anthropic、Mistral、Gemma 等;工作流配置中还支持通过 Ollama 使用本地模型。
- 任意文件:支持 PDF、TXT、Markdown 等文件,并且可以添加自己的解析器。
- 可定制 RAG:可以自定义 RAG,加入互联网搜索、添加工具等。
- 与 Megaparse 集成:可以用 Megaparse 完成文件摄入,再用 Quivr 做 RAG。
【使用方式概述】 官方描述为「我们负责 RAG,你负责产品」:安装 quivr-core 并加入项目,即可摄入文件并向其提问。仓库说明持续改进 RAG 并会增加更多特性。
【工作流能力】 来源给出了一个 Basic RAG 工作流的示例,其节点链为 START → filter_history → rewrite → retrieve → generate_rag → END(最后一个节点名用于把答案流式返回给用户)。配置中可设置 max_history(纳入答案上下文的历史对话轮数上限)、reranker_config(重排序供应商标识 supplier 与模型 model,示例为 cohere 的 rerank-multilingual-v3.
0,以及 top_n 返回的分块数量)、llm_config(max_input_tokens 传给 LLM 的最大 token 数、temperature)。
【适用对象】 需要把生成式 AI 问答/检索能力嵌入自有产品的应用开发者与团队;希望在本地或私有环境中使用自有模型(Ollama)的团队;需要自定义检索策略、重排序与解析器的高级用户。
【许可证】 Apache 2.0(详见仓库 LICENSE 文件)。
【信息说明】 来源未提供 quivr-core 的包体积、模型权重、参数规模、支持的模型参数规格、版本号、各语言的 SDK 支持情况、性能基准等,相关字段统一标注「待核验」,不做推测。
— 本文由 AI 根据公开来源辅助整理,命令、版本与许可证请在使用前到原始页面复核。
安装 / 开始使用
以下步骤严格按来源 README 整理(配图 1 为项目 Quivr-logo;配图 2 为 basic_rag 工作流示例示意图)。
一、准备环境(Prerequisites) 确保已安装 Python 3.10 或更高版本。
二、30 秒安装(30 seconds Installation) Step 1:安装包
pip install quivr-core # 来源注释:Check that the installation worked(确认安装成功)Step 2:用 5 行代码创建一个 RAG import tempfile from quivr_core import Brain
if __name__ == "__main__": with tempfile.NamedTemporaryFile(mode="w", suffix=".txt") as temp_file: temp_file.write("Gold is a liquid of blue-like colour.") temp_file.flush()
brain = Brain.from_files(
name="test_brain",file_paths=[temp_file.name],)
answer = brain.ask( "what is gold? asnwer in french" ) print("answer:", answer)
三、配置(Configuration)
import os os.environ["OPENAI_API_KEY"] = "myopenai_apikey" 来源说明:Quivr 支持 Anthropic、OpenAI、Mistral 的 API,也支持使用 Ollama 的本地模型。
- 把 API Key 加到环境变量中:
四、工作流
搭建 Basic RAG(Creating a basic RAG workflow)
workflow_config: name: "standard RAG" nodes:
- 创建 YAML 文件 basic_rag_workflow.yaml,写入以下内容:
edges: ["filter_history"]
edges: ["rewrite"]
edges: ["retrieve"]
edges: ["generate_rag"]
edges: ["END"]
- name: "START"
- name: "filter_history"
- name: "rewrite"
- name: "retrieve"
- name: "generate_rag" # the name of the last node, from which we want to stream the answer to the user
Maximum number of previous conversation iterations
to include in the context of the answer
max_history: 10
Reranker configuration
reranker_config:
The reranker supplier to use
supplier: "cohere"
The model to use for the reranker for the given supplier
model: "rerank-multilingual-v3.0"
Number of chunks returned by the reranker
top_n: 5
Configuration for the LLM
llm_config:
maximum number of tokens passed to the LLM to generate the answer
max_input_tokens: 4000
temperature for the LLM
temperature: 0.7
from quivr_core import Brain brain = Brain.from_files(name="my smart brain",
- 使用默认配置创建 Brain:
file_paths=["./my_first_doc.pdf", "./my_second_doc.txt"],)
brain.print_info()
- 启动一次对话(首次运行示例):
from rich.console import Console from rich.panel import Panel from rich.prompt import Prompt from quivr_core.config import RetrievalConfig
config_file_name = "./basic_rag_workflow.yaml" retrieval_config = RetrievalConfig.from_yaml(config_file_name)
console = Console() console.print(Panel.fit("Ask your brain !", style="bold magenta"))
while True:
Get user input
question = Prompt.ask("[bold cyan]Question[/bold cyan]")
Check if user wants to exit
if question.lower() == "exit": console.print(Panel("Goodbye!", style="bold yellow")) break answer = brain.ask(question, retrieval_config=retrieval_config)
Print the answer with typing effect
console.print(f"[bold green]Quivr Assistant[/bold green]: {answer.answer}") console.print("-" * console.width)
brain.print_info()
- 完成后即可与「大脑」对话,并只需修改配置文件来测试不同检索策略。
五、进阶 可以在 Quivr 之上继续添加互联网搜索、添加工具等能力,详见官方文档(Getting Started 一节指向 the documentation)。
六、常见问题(基于来源整理)
- 未配置密钥会无法调用模型:来源要求在环境变量中设置 OPENAI_API_KEY(或使用 Anthropic/Mistral 的 API、Ollama 本地模型)。
- 检索效果需要调参:来源建议通过修改 basic_rag_workflow.yaml 中的 max_history、reranker_config(supplier/model/top_n)与 llm_config(max_input_tokens、temperature)来对比不同检索策略。
- 仅安装 quivr-core 不会自带 UI/解析能力扩展:来源称可与 Megaparse 配合完成文件摄入;自定义解析器也需自行添加。
- 退出对话:在交互循环中输入 exit 即可退出(来源示例逻辑)。
