项目预览
项目数据
项目介绍
Star 增长趋势
本站每日记录该项目 GitHub 星标变化,观测越久曲线越完整
技术标签
使用教程
—
环境要求
- Python 3.10 或更高版本
- 可用的 pip 包管理工具
- 如需调用云端大模型,需自备对应 LLM 的访问凭据(README 未给出具体配置方式)
安装与启动步骤
-
1检查 Python 版本
README 要求 Python 3.10 或更新。先确认本机版本,低于 3.10 请先升级 Python。
python --version -
2安装 quivr-core
用 pip 安装核心包 quivr-core,安装完成后即可在自己的 Python 项目中导入使用。
pip install quivr-core -
3运行最小示例
把 README 的 5 行示例保存为 .py 文件并运行:创建一个临时 txt 文档、构建 Brain 并提问英文问题。
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) -
4编写 RAG 配置文件
新建 basic_rag_workflow.yaml,按 README 示例填写 reranker 与 llm 两组配置,之后可只改文件切换检索策略。
# 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 -
5加载配置并对话
用 RetrievalConfig.from_yaml 读取上面的配置文件,构建 Brain 后进入循环问答,输入 exit 退出。
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()
关键配置
| 配置项 | 必填 | 说明 | 示例 |
|---|---|---|---|
reranker_config.supplier | 否 | 指定使用的 reranker 供应商 | cohere |
reranker_config.model | 否 | 指定该供应商下使用的 reranker 模型 | rerank-multilingual-v3.0 |
reranker_config.top_n | 否 | reranker 返回的文本块数量 | 5 |
llm_config.max_input_tokens | 否 | 传给 LLM 生成答案的最大 token 数 | 4000 |
llm_config.temperature | 否 | LLM 采样温度,越高回答越发散 | 0.7 |
如何确认成功
运行最小示例后终端打印出以 answer: 开头的回答内容;运行对话脚本时会显示 Brain 信息并出现 Question 提示符。
常见问题
Q:需要什么 Python 版本?
A:README 明确要求 Python 3.10 或更新版本,低于该版本请先升级环境再安装。
Q:支持哪些大模型?
A:README 称 Quivr 可与任何 LLM 配合,例如 OpenAI、Anthropic、Mistral、Gemma 等。
Q:能处理哪些文件类型?
A:支持任意文件,如 PDF、TXT、Markdown 等,还可以自行添加解析器;示例中用了 .pdf 和 .txt。
Q:怎么更换检索策略?
A:只需修改 YAML 配置文件(如 reranker_config、llm_config)后重新运行,无需改动代码。
Q:更多文档在哪里?
A:README 指向官方文档 https://core.quivr.com/,安装与配置细节以该文档为准。
注意事项
- README 未说明 API Key 等模型凭据的配置方式,接入云端 LLM 前请查阅官方文档 core.quivr.com。
- 安装的包名是 quivr-core,代码中导入的模块名是 quivr_core,注意两者拼写差异。
- 不传 retrieval_config 时 Brain 会使用默认配置,即 README 所说的“有主见”的默认 RAG。
- README 中的安装章节有一处内容被截断(pip in ...),本教程只采用了完整的 pip install quivr-core 命令。
核心亮点
- 支持 GPT-4、Groq、Llama 等多种 LLM,灵活切换
- 兼容 PGVector、Faiss 等主流向量库,数据存储自由
- 提供现成 API 和前端组件,集成门槛低
不足之处
- 配置项较多,初学者需花时间理解
- 文档/社区待观察
适用场景
- 企业内部知识库问答系统
- 电商客服智能助手
- 文档检索与摘要生成工具
替代项目
LangChain、LlamaIndex、Haystack
上一篇:llm-applications
下一篇:jonex
同类项目推荐
firecrawl
开源
网页抓取像喝水一样简单,开发者省下整周加班
Supercharge your AI agents with data from the web and beyond. Building the library f···
graphify
开源
整个代码库画成一张图,找问题一眼定位
Turn any codebase, with its docs, SQL schemas, configs, and PDFs, into a queryable k···
contoso-chat
开源
一键跑通 Azure RAG 应用,从代码到评估部署全流程
This sample has the full End2End process of creating RAG application with Prompty an···
WeKnora
开源
文档往里一扔,自动变成啥都能答的知识库
Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an auto···
