PineconeUtils
v0.0.4
Pineconeutils是一個Python模塊,旨在處理和處理使用Pinecone,Cohere和OpenAI服務嵌入和索引的數據。該實用程序模塊使其易於加載,塊,準備和UPSERT數據到Pinecone索引中,非常適合涉及涉及文本嵌入和檢索系統(RAG)的應用程序。
.txt , .docx和.pdf文件加載文本數據。要安裝Pineconeutils,您可以使用PIP:
pip install pineconeutils這是如何使用Pineconeutils的一個快速示例:
首先,確保您擁有必要的API鍵和設置信息:
pinecone_api_key = " your_pinecone_api_key "
cohere_api_key = " your_cohere_api_key "
openai_api_key = " your_openai_api_key "
index_name = " your_index_name "
namespace_id = " your_namespace_id "從受支持的文件格式加載數據:
from pineconeutils import PineconeUtils
# Create instance of PineconeUtils
pinecone = PineconeUtils(pinecone_api_key=pinecone_api_key, openai_api_key=openai_api_key,cohere_api_key =cohere_api_key, index_name=index_name, namespace_id=namespace_id)
path = " path_to_your_file.docx "
data = pinecone.load_data(path)
print( " Loaded Data: " , data)chunks = pinecone.chunk_data(data, chunk_size=100, chunk_overlap=10)
print( " Data Chunks: " , chunks)
prepared_data = pinecone.prepare_data(chunks, model= " text-embedding-ada-002 " , service= " openai " )chunks = pinecone.chunk_data(data, chunk_size=100, chunk_overlap=10)
print( " Data Chunks: " , chunks)
prepared_data = pinecone.prepare_data(chunks, model= " embed-english-v3.0 " , service= " cohere " ,input_type= " search_document " )有關鑲嵌嵌入的更多信息:膜嵌入
successful = pinecone.upsert_data(prepared_data)
print( " Data upsertion was " , " successful " if successful else " unsuccessful " )為了為Pineconeutil的開發做出貢獻,您可以克隆存儲庫並提交拉動請求。
如果您遇到任何問題或有疑問,請在GitHub存儲庫上提出問題。
該項目是根據MIT許可證獲得許可的 - 有關詳細信息,請參見許可證文件。