Skip to main content

Records plugin for Pinecone SDK

Project description

Records API plugin for Pinecone python SDK

Installation

The plugin is distributed separately from the core python SDK.

# Install the base python SDK, version 5.4.0 or higher
pip install pinecone

# And also the plugin functionality
pip install pinecone-plugin-records

Usage

This plugin extends the functionality of the pinecone SDK to allow creating indexes for specific embedding models, and upserting and searching records in these indexes. These operations are added to the existing Pinecone and Index classes.

Models currently supported:

Create an index for an embedding model, upsert records, and search

The following example highlights how to use the Pinecone class to create a new index for an embedding model, and then uses Index to upsert and query some records.

from pinecone import Pinecone

pc = Pinecone(api_key="<<PINECONE_API_KEY>>")

# Create an index for your embedding model
index_model = pc.create_index_for_model(
    model="multilingual-e5-large",
    field_map={"text": "my_text_field"},
    name="my-model-index",
    cloud="aws",
    region="us-east-1",
)

# establish an index connection
index = pc.Index(host=index_model.host)

# upsert records
index.upsert_records(
    "my-namespace",
    [
        {
            "_id": "test1",
            "my_text_field": "Apple is a popular fruit known for its sweetness and crisp texture.",
        },
        {
            "_id": "test2",
            "my_text_field": "The tech company Apple is known for its innovative products like the iPhone.",
        },
        {
            "_id": "test3",
            "my_text_field": "Many people enjoy eating apples as a healthy snack.",
        },
        {
            "_id": "test4",
            "my_text_field": "Apple Inc. has revolutionized the tech industry with its sleek designs and user-friendly interfaces.",
        },
        {
            "_id": "test5",
            "my_text_field": "An apple a day keeps the doctor away, as the saying goes.",
        },
        {
            "_id": "test6",
            "my_text_field": "Apple Computer Company was founded on April 1, 1976, by Steve Jobs, Steve Wozniak, and Ronald Wayne as a partnership.",
        },
    ],
)

# search for similar records
response = index.search_records(
    namespace="test-namespace", inputs={"text": "Apple corporation"}, top_k=3
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

File details

Details for the file pinecone_plugin_records-0.1.0.dev20241031041416.tar.gz.

File metadata

File hashes

Hashes for pinecone_plugin_records-0.1.0.dev20241031041416.tar.gz
Algorithm Hash digest
SHA256 25f766685eea87000ba998db835159fd4f15fa93c0e43b54b2b7de63b2223aab
MD5 7d46ae1b9aa9661df45afec38b94be69
BLAKE2b-256 744ff177ff5a106d82acad36d709d7caf1a99a359d738fffc2239c7188c5bedc

See more details on using hashes here.

File details

Details for the file pinecone_plugin_records-0.1.0.dev20241031041416-py3-none-any.whl.

File metadata

File hashes

Hashes for pinecone_plugin_records-0.1.0.dev20241031041416-py3-none-any.whl
Algorithm Hash digest
SHA256 828df3f3bc87964e8427bb59c7b459b76f70cf6d316be9c594e9d9ee2b727963
MD5 b28b5d7d6d02e7b435971803ccde7a3a
BLAKE2b-256 93fb5d3e330b3f61c04cf30e506ebde6d77c0d07134131771b4d16eaface538d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page