Skip to main content

PineconeUtils

PineconeUtils is a Python module designed to handle and process data for embedding and indexing using Pinecone, Cohere, and OpenAI services. This utility module makes it easy to load, chunk, prepare, and upsert data into a Pinecone index, making it ideal for applications involving text embedding and retrieval systems(RAG).

Features

  • Load text data from .txt, .docx, and .pdf files.
  • Chunk text data for processing.
  • Prepare embeddings using either Cohere or OpenAI models.
  • Upsert prepared data into a Pinecone index.

Installation

To install PineconeUtils, you can use pip:

pip install pineconeutils

Usage

Here's a quick example of how to use PineconeUtils:

Setup

First, ensure you have the necessary API keys and setup information:

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"

Load Data

Load data from a supported file format:

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)

Process Data

Chunk and prepare data for embedding:

For openai

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")

For cohere

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")

For more about Cohere Embeddings: Cohere Embeddings

Upsert Data

Upsert data into Pinecone index:

successful = pinecone.upsert_data(prepared_data)
print("Data upsertion was", "successful" if successful else "unsuccessful")

Development

To contribute to the development of PineconeUtils, you can clone the repository and submit pull requests.

Support

If you encounter any issues or have questions, please file an issue on the GitHub repository.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Metadata

Release files for pineconeutils 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pineconeutils 0.0.4
File Size Uploaded
pineconeutils-0.0.4.tar.gz 7.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pineconeutils 0.0.4
File Interpreter ABI Platform
pineconeutils-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 14.7 kB

Release files / pineconeutils-0.0.4.tar.gz

Download URL pineconeutils-0.0.4.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
21b8a6cf6089869650c06824c6e53d234182de21b6f5063ca89f7ca159683ccb
BLAKE2b-256 checksum
How to use checksums
fa52a57b518653f62785ac4618fd57be3cc2714687472bba7e41fccd608d84b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.9.19

Release files / pineconeutils-0.0.4-py3-none-any.whl

Download URL pineconeutils-0.0.4-py3-none-any.whl
Size 7.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6b464a5552de6d5e83b31e33604054bf7341dc6b31068ca4f2a5ade113ae70b5
BLAKE2b-256 checksum
How to use checksums
13dff3b458bda18e1d266dcdd475efedf7f0aacf33448ab22ba06e5537d90926
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.9.19

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page