奎弗尔
core:
Quivr,帮你打造第二大脑,利用GenerativeAI的力量,做你的私人助理!
我们会照顾 RAG,以便您可以专注于您的产品。只需安装 quivr-core 并将其添加到您的项目中即可。您现在可以提取文件并提出问题。*
我们将改进 RAG 并添加更多功能,敬请期待!
这是 Quivr 的核心,Quivr.com 的大脑。
您可以在文档中找到所有内容。
确保您已安装以下软件:
第 1 步:安装软件包
pip install quivr-core # Check that the installation worked
步骤 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 )
创建像上面这样的基本 RAG 工作流程很简单,步骤如下:
import os
os . environ [ "OPENAI_API_KEY" ] = "myopenai_apikey"
Quivr 支持 Anthropic、OpenAI 和 Mistral 的 API。它还支持使用 Ollama 的本地模型。
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
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。查看文档以获取更多信息。
感谢这些优秀的人:
你收到拉取请求了吗?打开它,我们会尽快审核。请在此处查看我们的项目板,了解我们当前的重点,并随时提出您的新想法!
如果没有我们合作伙伴的支持,这个项目就不可能实现。感谢您的支持!
该项目根据 Apache 2.0 许可证获得许可 - 有关详细信息,请参阅许可证文件