Pinecone Inference Plugin (Deprecated)

3.1.0 · deprecated · verified Mon Apr 13

This library, `pinecone-plugin-inference`, was an embeddings plugin for the Pinecone SDK, providing early access to Pinecone's Inference APIs for tasks like generating embeddings. As of Pinecone SDK version 5.0.0, the functionality provided by this plugin has been integrated directly into the main `pinecone` SDK. Therefore, this plugin is effectively deprecated for users running Pinecone SDK v5.0.0 or newer. The current version is 3.1.0, released in December 2024, but its separate installation is no longer recommended.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates the general approach to using Pinecone's inference capabilities, which now are integrated directly into the main `pinecone` SDK (v5.0.0+). The `pinecone-plugin-inference` library is no longer necessary. The example initializes the Pinecone client and illustrates where inference operations (like embedding generation) would typically be performed. Users should consult the latest Pinecone Python SDK documentation for the most accurate and up-to-date methods and model availability.

import os
from pinecone import Pinecone

# Ensure PINECONE_API_KEY and PINECONE_ENVIRONMENT (or PINECONE_CLOUD/PINECONE_REGION for serverless) are set as environment variables
api_key = os.environ.get('PINECONE_API_KEY', 'YOUR_API_KEY')
# For serverless indexes, use CloudProvider and region directly with Pinecone(cloud=CloudProvider.AWS, region=AwsRegion.US_EAST_1)
# For older pod-based indexes, use environment=os.environ.get('PINECONE_ENVIRONMENT', 'YOUR_ENVIRONMENT')

# Initialize Pinecone client (inference capabilities are now integrated)
pc = Pinecone(api_key=api_key)

# Example: Generate embeddings using the integrated inference API
documents = [
    'The quick brown fox jumps over the lazy dog.',
    'Python is a high-level, interpreted programming language.'
]

try:
    # As of pinecone SDK v5.0.0+, inference functionality is directly available
    # The exact method signature may vary slightly with new versions, always refer to current docs.
    # Example with a common embedding model (e.g., 'text-embedding-ada-002' or similar)
    # Note: Model availability and exact method names can change.
    # Check Pinecone documentation for current available models and usage.
    
    # This is a general example, specific model names and parameters should be checked with current Pinecone docs.
    # If using serverless, `cloud` and `region` are passed at Pinecone client initialization.
    
    # This example assumes a method like 'embed_documents' or 'generate_embeddings' exists under 'pc.inference'
    # For the most up-to-date quickstart, refer to the Pinecone Python SDK documentation.
    print("Attempting to generate embeddings...")
    # This part is illustrative; actual method name/parameters might differ slightly.
    # The concept is that `pc.inference` will expose embedding generation.
    
    # A more realistic example from current Pinecone SDK (v7.x) for integrated inference:
    # from pinecone import Index, PodSpec
    # index_name = 'my-integrated-index'
    # if index_name not in pc.list_indexes():
    #     pc.create_index(
    #         name=index_name,
    #         dimension=1536, # Example dimension, depends on the embedding model
    #         metric='cosine',
    #         spec=PodSpec(environment='gcp-starter') # or ServerlessSpec
    #     )
    # index = pc.Index(index_name)
    # result = index.upsert(vectors=[{'id': f'doc{i}', 'values': pc.embed_text(text=doc), 'metadata': {'text': doc}} for i, doc in enumerate(documents)])
    # print(f"Upserted documents: {result}")
    
    # Placeholder for direct inference call as per older plugin concept, but now through main SDK:
    # The actual method name and arguments depend on the Pinecone SDK version and specific API.
    # As of pinecone v7.x, embedding is often done via `index.upsert` with `pc.embed_text` or similar.
    # For direct embedding generation without upserting to an index immediately, you'd look for methods exposed on the Pinecone client or a dedicated inference client if one exists.
    
    # Since pinecone-plugin-inference is deprecated, the quickstart should reflect current SDK usage.
    print("Please refer to the official Pinecone Python SDK documentation for the latest quickstart on integrated inference and embedding generation.")
    print("This plugin is no longer needed for SDK versions 5.0.0+.")

except Exception as e:
    print(f"An error occurred: {e}")
    print("Ensure your Pinecone API key and environment/cloud configuration are correct and that you are using Pinecone SDK v5.0.0 or higher for integrated inference.")

view raw JSON →