Quivr:由生成式 AI 驱动的第二大脑 RAG 框架
英文标题:📦 The-Vibe-Company/quivr
Quivr 是一个面向产品集成的“有明确取舍”的 RAG 框架,旨在让开发者将检索增强生成能力快速接入现有应用,而无需自行处理复杂的 RAG 基础设施。它支持 OpenAI、Anthropic、Mistral 等 API,也支持通过 Ollama 使用本地模型,并可处理 PDF、TXT、Markdown 等多种文件格式及自定义解析器。开发者可通过 YAML 配置工作流、重排序器和 LLM 参数,并扩展互联网搜索、工具调用等能力。该项目还可与 Megaparse 集成,用于文档导入和解析。
138.8 KB
191.1 KB
3.8 KB
147.3 KB
中文
Quivr:由生成式 AI 驱动的第二大脑
Quivr 可帮助你构建自己的第二大脑,利用生成式 AI 的能力成为你的个人助手!
- 有明确取舍的 RAG:我们打造了一个具有明确设计取舍、快速且高效的 RAG,让你能够专注于自己的产品。
- LLM:Quivr 可与任何 LLM 配合使用,包括 OpenAI、Anthropic、Mistral、Gemma 等。
- 任意文件:Quivr 支持任意文件,可用于 PDF、TXT、Markdown 等格式,也可添加你自己的解析器。
- 自定义 RAG:Quivr 允许你定制 RAG,包括加入互联网搜索、工具等能力。
- 与 Megaparse 集成:Quivr 可与 Megaparse 配合使用,因此你可以通过 Megaparse 导入文件,再使用 Quivr 的 RAG。
我们负责处理 RAG,让你可以专注于产品。只需安装 quivr-core 并将其添加到项目中,即可导入文件并提问。*
我们将持续改进 RAG 并添加更多功能,敬请关注!
这是 Quivr 的核心,也是 Quivr.com 的大脑。
你可以在文档中找到完整内容。
请确保已安装以下内容:
30 秒安装 💽
创建如上所示的基础 RAG 工作流非常简单,步骤如下:
- 将 API Key 添加至环境变量。
import os
os.environ["OPENAI_API_KEY"] = "myopenai_apikey"
Quivr 支持 Anthropic、OpenAI 和 Mistral 的 API,也支持通过 Ollama 使用本地模型。
- 创建 YAML 文件
basic_rag_workflow.yaml,并将以下内容复制到其中。
workflow_config:
name: "standard RAG"
nodes:
- name: "START"
edges: ["filter_history"]
- name: "filter_history"
edges: ["rewrite"]
- name: "rewrite"
edges: ["retrieve"]
- name: "retrieve"
edges: ["generate_rag"]
- name: "generate_rag" # the name of the last node, from which we want to stream the answer to the user
edges: ["END"]
# 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
- 使用默认配置创建一个 Brain。
from quivr_core import Brain
brain = Brain.from_files(name = "my smart 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 进一步添加互联网搜索、工具等能力。更多信息请参阅文档。
如果你提交了 Pull Request,请打开它,我们会尽快审查。你可以在这里查看项目看板,了解我们当前的重点工作,也欢迎提出你的新想法!
没有合作伙伴的支持,这个项目不可能实现。感谢你们的支持!
本项目采用 Apache 2.0 许可证授权,详情请参阅 LICENSE 文件。
English / 原文
Quivr - Your Second Brain, Empowered by Generative AI
Quivr, helps you build your second brain, utilizes the power of GenerativeAI to be your personal assistant !
- Opiniated RAG : We created a RAG that is opinionated, fast and efficient so you can focus on your product
- LLMs : Quivr works with any LLM, you can use it with OpenAI, Anthropic, Mistral, Gemma, etc.
- Any File : Quivr works with any file, you can use it with PDF, TXT, Markdown, etc and even add your own parsers.
- Customize your RAG : Quivr allows you to customize your RAG, add internet search, add tools, etc.
- Integrations with Megaparse : Quivr works with Megaparse, so you can ingest your files with Megaparse and use the RAG with Quivr.
We take care of the RAG so you can focus on your product. Simply install quivr-core and add it to your project. You can now ingest your files and ask questions.*
We will be improving the RAG and adding more features, stay tuned!
This is the core of Quivr, the brain of Quivr.com.
You can find everything on the documentation.
Ensure you have the following installed:
30 seconds Installation 💽
Creating a basic RAG workflow like the one above is simple, here are the steps:
- Add your API Keys to your environment variables
import os
os.environ["OPENAI_API_KEY"] = "myopenai_apikey"
Quivr supports APIs from Anthropic, OpenAI, and Mistral. It also supports local models using Ollama.
- Create the YAML file
basic_rag_workflow.yamland copy the following content in it
workflow_config:
name: "standard RAG"
nodes:
- name: "START"
edges: ["filter_history"]
- name: "filter_history"
edges: ["rewrite"]
- name: "rewrite"
edges: ["retrieve"]
- name: "retrieve"
edges: ["generate_rag"]
- name: "generate_rag" # the name of the last node, from which we want to stream the answer to the user
edges: ["END"]
# 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
- Create a Brain with the default configuration
from quivr_core import Brain
brain = Brain.from_files(name = "my smart brain",
file_paths = ["./my_first_doc.pdf", "./my_second_doc.txt"],
)
- Launch a Chat
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()
- You are now all set up to talk with your brain and test different retrieval strategies by simply changing the configuration file!
You can go further with Quivr by adding internet search, adding tools, etc. Check the documentation for more information.
Thanks go to these wonderful people:
Did you get a pull request? Open it, and we'll review it as soon as possible. Check out our project board here to see what we're currently focused on, and feel free to bring your fresh ideas to the table!
This project would not be possible without the support of our partners. Thank you for your support!
This project is licensed under the Apache 2.0 License - see the LICENSE file for details
