Skip to main content

A Streamlit extension for connecting to Pinecone indexes.

Project description

Streamlit Pinecone Connection

This repo includes the PineconeConnection class, an st.connection wrapper for integrating the Pinecone API into Streamlit applications. It facilitates the use of Pinecone's powerful indexing and querying capabilities directly within Streamlit, making it ideal for building sophisticated search and data retrieval applications.

Features

  • Instantiate Pinecone Index: Seamlessly connect to a Pinecone index.
  • Rich Query Capabilities: Perform queries with embeddings, retrieve top_k similar items.
  • Index Insights: Gather statistics about the Pinecone index's contents.
  • Comprehensive Vector Operations: Includes methods for deleting, updating, fetching, and upserting vectors in a namespace.
  • Caching for Performance: Results from various methods are cached to enhance the performance of your Streamlit app.

Installation

Install the package using pip:

pip install streamlit-pinecone

Usage

Import and initialize the connection in your Streamlit app:

from streamlit_pinecone import PineconeConnection

# Initialize the connection
conn = PineconeConnection(api_key='your_api_key', environment='your_environment', index_name='your_index_name')

# Use the connection
results = conn.query([...])

Example

Movie Matcher Demo

For a live demo, check out Movie Matcher!

You can find the source code under \demo\ directory.

Documentation

PineconeConnection Class

The PineconeConnection class provides methods to interact with Pinecone indexes within a Streamlit app.


index()

Returns: pinecone.Index
Description: Returns the Pinecone index instance.


query(embeddings, top_k=10, ttl=3600, **kwargs)

Parameters:

  • embeddings: List of embeddings for the query.
  • top_k (int, optional): Number of top similar items to return. Default is 10.
  • ttl (int, optional): Time-to-live for cache in seconds. Default is 3600.
    Returns: Dictionary of query results.
    Description: Queries the Pinecone index with provided embeddings.

describe_index_stats(ttl=3600, **kwargs)

Parameters:

  • ttl (int, optional): Time-to-live for cache in seconds. Default is 3600.
    Returns: String describing index statistics.
    Description: Provides statistics about the Pinecone index's contents.

delete(ids, delete_all=None, namespace=None, filter=None, ttl=3600, **kwargs)

Parameters:

  • ids (list): List of IDs to delete.
  • delete_all (bool, optional): Flag to delete all vectors.
  • namespace (str, optional): Namespace from which to delete.
  • filter (dict, optional): Filter criteria for deletion.
  • ttl (int, optional): Time-to-live for cache in seconds.
    Returns: Dictionary of deletion results.
    Description: Deletes vectors by ID from a namespace.

update(id, values=None, sparse_values=None, set_metadata=None, namespace=None, ttl=3600, **kwargs)

Parameters:

  • id (str): ID of the vector to update.
  • values, sparse_values, set_metadata: Data for update.
  • namespace (str, optional): Namespace to update.
  • ttl (int, optional): Time-to-live for cache in seconds.
    Returns: Dictionary of update results.
    Description: Updates a vector in a namespace.

fetch(ids, ttl=3600, namespace=None, **kwargs)

Parameters:

  • ids (list): List of IDs to fetch.
  • ttl (int, optional): Time-to-live for cache in seconds.
  • namespace (str, optional): Namespace to fetch from.
    Returns: Dictionary of fetched vectors.
    Description: Fetches vectors by ID from a namespace.

upsert(vectors, ttl=3600, namespace=None, **kwargs)

Parameters:

  • vectors (list): List of vectors to upsert.
  • ttl (int, optional): Time-to-live for cache in seconds.
  • namespace (str, optional): Namespace to upsert into.
    Returns: Dictionary of upsert results.
    Description: Writes vectors into a namespace.

License

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


For more information, visit the GitHub repository.

Contact

Eliot Lee - eliotlee2026@u.northwestern.edu

Acknowledgments

Special thanks to the Streamlit team and the Streamlit Developer Relations team for their support and for featuring this project in the Streamlit components gallery.

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

streamlit-pinecone-1.0.0.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

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

streamlit_pinecone-1.0.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file streamlit-pinecone-1.0.0.tar.gz.

File metadata

  • Download URL: streamlit-pinecone-1.0.0.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for streamlit-pinecone-1.0.0.tar.gz
Algorithm Hash digest
SHA256 b28d0e0a32136c356068a751aa42756550c0a73e50d31804a123adbc35a3ddcb
MD5 178169274afae7d2d471af46c6b66d09
BLAKE2b-256 b3ef86827d4a5a17ee4656b2707c29245b9caeec50a37a3b3cf97f14f93ac3e2

See more details on using hashes here.

File details

Details for the file streamlit_pinecone-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_pinecone-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d235843ea13c2cdd877309d8c7b7b9883dbfcff6d1e4b4624401814402a00717
MD5 8525cc5fedfb9d23bd0847abbc1f6197
BLAKE2b-256 0643e24e39035566e44d0c3bb19a43aac94899358c270c53fe383108317496a0

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