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 search 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(
    name="my-model-index",
    cloud="aws",
    region="us-east-1",
    embed={"model":"multilingual-e5-large", "field_map":{"text": "my_text_field"}}
)

# 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",
    query={
        "inputs":{
            "text": "Apple corporation",
        },
        "top_k":3,
    },
    rerank={
        "model": "bge-reranker-v2-m3",
        "rank_fields": ["my_text_field"],
        "top_n": 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

pinecone_plugin_records-0.4.0.tar.gz (110.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pinecone_plugin_records-0.4.0-py3-none-any.whl (278.5 kB view details)

Uploaded Python 3

File details

Details for the file pinecone_plugin_records-0.4.0.tar.gz.

File metadata

  • Download URL: pinecone_plugin_records-0.4.0.tar.gz
  • Upload date:
  • Size: 110.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.5.0-1025-azure

File hashes

Hashes for pinecone_plugin_records-0.4.0.tar.gz
Algorithm Hash digest
SHA256 ec9b3ce7f56a1ec5e5267ad1a75280fd51492c1f6f24253fdccb44cdc0f26907
MD5 bfbd5dc17a3facefc35f89d15b4261d0
BLAKE2b-256 8f03f9f613c3aea5a61013457e4a035ee3900ca304e0af111788b0a9ce2b4752

See more details on using hashes here.

File details

Details for the file pinecone_plugin_records-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pinecone_plugin_records-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cc0fb21a27d2378efcdd1a146c6352a0f176d281878316f6ff9e58d69bf8d2c0
MD5 a9bb3b29b42895334e848b8abfb30a8b
BLAKE2b-256 d785ab783c0877f8a091d38012a6b81d31df0054f327fac13e200dd02c8dcb27

See more details on using hashes here.

Supported by

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