Pineconeutils เป็นโมดูล Python ที่ออกแบบมาเพื่อจัดการและประมวลผลข้อมูลสำหรับการฝังและการจัดทำดัชนีโดยใช้ Pinecone, Cohere และ OpenAI Services โมดูลยูทิลิตี้นี้ทำให้ง่ายต่อการโหลดชิ้นส่วนเตรียมและข้อมูลขึ้นในดัชนี 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 " )สำหรับข้อมูลเพิ่มเติมเกี่ยวกับการฝังตัวของ Coeler: Cohere Embeddings
successful = pinecone.upsert_data(prepared_data)
print( " Data upsertion was " , " successful " if successful else " unsuccessful " )ในการมีส่วนร่วมในการพัฒนา pineconeutils คุณสามารถโคลนที่เก็บและส่งคำขอดึง
หากคุณพบปัญหาใด ๆ หรือมีคำถามโปรดยื่นปัญหาเกี่ยวกับที่เก็บ GitHub
โครงการนี้ได้รับใบอนุญาตภายใต้ใบอนุญาต MIT - ดูไฟล์ใบอนุญาตสำหรับรายละเอียด