Quivr 是一個開源的全棧檢索增強生成 (RAG) 平台,專注於將生成式 AI 整合到應用程式中。該項目的核心理念是讓開發者專注於產品本身,而不是複雜的 RAG 實現細節。
Quivr 支援多種 LLM 模型,包括:
支援多種文件格式:
支援多種向量儲存解決方案:
Quivr 採用基於節點的工作流配置:
pip install quivr-core
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? answer in french"
)
print("answer:", answer)
import os
os.environ["OPENAI_API_KEY"] = "your_openai_api_key"
創建工作流配置文件 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"
edges: ["END"]
max_history: 10
reranker_config:
supplier: "cohere"
model: "rerank-multilingual-v3.0"
top_n: 5
llm_config:
max_input_tokens: 4000
temperature: 0.7
from quivr_core import Brain
from rich.console import Console
from rich.panel import Panel
from rich.prompt import Prompt
from quivr_core.config import RetrievalConfig
brain = Brain.from_files(
name="my smart brain",
file_paths=["./my_first_doc.pdf", "./my_second_doc.txt"],
)
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:
question = Prompt.ask("[bold cyan]Question[/bold cyan]")
if question.lower() == "exit":
console.print(Panel("Goodbye!", style="bold yellow"))
break
answer = brain.ask(question, retrieval_config=retrieval_config)
console.print(f"[bold green]Quivr Assistant[/bold green]: {answer.answer}")
console.print("-" * console.width)
brain.print_info()
Quivr 可以自動化高達 60% 的客戶服務任務,利用 AI 的力量提高客戶滿意度和價值。
Quivr 為開發者提供了一個強大、靈活且易於使用的 RAG 平台,無論是個人項目還是企業級應用,都能快速構建智能的文檔問答系統。其開源的特性和活躍的社區支援使其成為構建"第二大腦"應用的理想選擇。