Compendium Keeper是一种将汇编数据(由Compendium Scribe生成)索引到矢量数据库(例如Pinecone)的工具,以供电检索结果(RAG)工作流程。
.compendium.pickle和.compendium.xml文件格式。 git clone https://github.com/yourusername/compendiumkeeper.git
cd compendiumkeeper确保您安装了PDM。然后运行:
pdm install在项目的根目录中创建.env文件,以存储您的API键和配置。您可以将提供的.env.example用作模板。
.env文件 # .env.example
# OpenAI API Key for generating embeddings
OPENAI_API_KEY = sk-your-openai-api-key
# Pinecone API Key and Environment
PINECONE_API_KEY = your-pinecone-api-key
PINECONE_ENVIRONMENT = us-east-1-aws重命名.env.example为.env并用实际的API键替换占位符值。
compendium-scribe-create-compendium --domain " Cell Biology "这会产生诸如cell_biology_2024-12-05.compendium.pickle和cell_biology_2024-12-05.compendium.xml之类的文件。
使用--compendium-file选项来指定Compendium File(Pickle或XML)。
您还必须使用--index-name选项指定矢量数据库索引名称。
确保使用必要的API键正确配置.env文件。
pdm run compendium-keeper index --compendium-file cell_biology_2024-12-05.compendium.pickle --index-name my_knowledge_indexpdm run compendium-keeper index --compendium-file cell_biology_2024-12-05.compendium.xml --index-name my_knowledge_index成功执行后,您应该看到一条确认消息,指示索引的概念数量。
Indexed 25 concepts from domain 'Cell Biology' into index 'my_knowledge_index'.
Indexing complete!
要创建一个跨越多组件的单个知识库,请使用相同的--index-name重复每个汇编的索引过程。
例如:
pdm run compendium-keeper index --compendium-file django_2024-12-10.compendium.pickle --index-name all_python_knowledge
pdm run compendium-keeper index --compendium-file flask_2024-12-10.compendium.xml --index-name all_python_knowledge这将使从多个compendia的知识合并为同一矢量数据库索引。
vector_db/ Directory中实现新类来添加对其他矢量数据库(例如编织,Chromadb)的支持。utils.py以自定义嵌入方式的生成或处理。 设置环境变量
如上所述创建一个.env文件。
产生纲要
使用Compendium Scribe以腌制或XML格式生成纲要。
带有纲要的索引
运行索引命令将嵌入到您选择的矢量数据库中。
缺少API键
确保您的.env文件包含所有必需的API键。如果丢失了,CLI将通知您。
不支持的矢量数据库
目前,仅支持松果。要添加对另一个矢量数据库的支持,请在vector_db/遵守VectorDatabase抽象基类中实现新类。
文件格式问题
确保您在.compendium.pickle或.compendium.xml中提供的--compendium-file 。不支持具有其他扩展名的文件。
API速率限制
在索引大型汇编时,请注意OpenAI的API速率限制。考虑到必要时考虑实施分批或限制费用。
欢迎捐款!随时打开问题或提交拉动请求。
Compendium Keeper由MIT许可发布。