Registry / vector-search / pinecone-plugin-interface

pinecone-plugin-interface

JSON →
library0.0.7pypypi✓ verified 25d ago

The Pinecone Plugin Interface provides base classes and models for developing custom plugins that extend the functionality of the Pinecone Python client. This allows users to implement custom logic for tasks like query pre-processing (text plugins) or result post-processing (filter plugins). The current version is 0.0.7, indicating an early-stage library with potential for frequent updates.

pip install pinecone-plugin-interface
INSTALL
IMPORT
SIG · PINECONE-PLUGIN-IN
P
pinecone-plugin-interface
vector-searchpythonv0.0.7
Install
1.5s avg
Import
59ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.0.7 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.060s · 17.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.058s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PineconePlugin
from pinecone_plugin_interface import PineconePlugin
from pinecone_plugin_interface.plugin import Plugin
PluginMetadata
from pinecone_plugin_interface import PluginMetadata
discover_plugins
from pinecone_plugin_interface import discover_plugins

This quickstart demonstrates how to define a simple `FilterPlugin` that intercepts and modifies a filter parameter. The core idea is to subclass `FilterPlugin` (or `TextPlugin`) and implement the `run` asynchronous method. The example shows capitalizing a 'category' filter value. To activate such a plugin, you must instantiate it and then register it with a specific `Pinecone` index instance using `index.register_plugin(plugin_instance)`.

from pinecone_plugin_interface.plugin import FilterPlugin from pinecone_plugin_interface.models import FilterPluginRequest, FilterPluginResponse from typing import Dict, Any import os class CapitalizeCategoryFilterPlugin(FilterPlugin): """ An example filter plugin that adds a simple metadata filter to capitalize the 'category' field for demonstration purposes, effectively applying a filter like {'category': {'$eq': 'DOCS'}}. """ def __init__(self, name: str = "capitalize-category-filter", description: str = "Capitalizes category for filtering"): super().__init__(name=name, description=description) async def run(self, request: FilterPluginRequest) -> FilterPluginResponse: # Assume a 'category' key exists in request.metadata or is expected in the filter if request.filter and 'category' in request.filter: # This example demonstrates modification; in a real scenario, # you might look for specific filter patterns to modify. # Here, we just illustrate returning a modified filter. modified_filter = {"category": {"$eq": request.filter['category'].upper()}} else: # If no category filter is present, we could add a default or pass through modified_filter = request.filter return FilterPluginResponse(filter=modified_filter) # To use this plugin, you would typically register it with a Pinecone index: # from pinecone import Pinecone # # Ensure PINECONE_API_KEY and PINECONE_ENVIRONMENT are set in your environment # pc = Pinecone(api_key=os.environ.get('PINECONE_API_KEY', 'TEST_API_KEY'), # environment=os.environ.get('PINECONE_ENVIRONMENT', 'us-west-2')) # index = pc.Index("my-index") # Replace with your index name # # plugin_instance = CapitalizeCategoryFilterPlugin() # index.register_plugin(plugin_instance) # # print(f"Plugin '{plugin_instance.name}' registered. Its description is: '{plugin_instance.description}'") # # You can then call index.query with the plugin applied through a 'plugin_params' argument: # # query_results = index.query(vector=[0.1, ...], top_k=5, plugin_params={'my-plugin-name': {'category': 'docs'}})
Debug
Known issues
breakingAs a 0.0.x series library, the API is subject to rapid change. Expect potential breaking changes to class signatures, method names, and model structures without major version bumps.
fix
Always pin the exact minor version (e.g., `pinecone-plugin-interface==0.0.7`) and thoroughly review release notes upon upgrading.
affects: <1.0.0
gotchaThis library provides interfaces, not pre-built plugins. Users must implement the specific logic for their desired plugins by subclassing `TextPlugin` or `FilterPlugin`.
fix
Understand that the library defines the contract; you are responsible for writing the plugin's `run` method logic.
affects: <1.0.0
gotchaRequires `pinecone-client>=3.0.0`. Older versions of the Pinecone client do not support the plugin registration mechanism and will raise errors.
fix
Ensure `pinecone-client` is updated to version 3.0.0 or higher (`pip install 'pinecone-client>=3.0.0'`).
affects: <1.0.0
gotchaPlugins must be explicitly registered with a Pinecone index instance (e.g., `index.register_plugin(my_plugin_instance)`) before they can be used. Forgetting this step will mean the plugin is not active.
fix
After instantiating your plugin, call the `register_plugin` method on your `pinecone.Index` object.
affects: <1.0.0
Upgrade
Version history
0.0.7latest on PyPI · released Jun 5, 2024
Audit
Dependencies
pinecone-clientrequiredRequired to register and interact with plugins within a Pinecone index instance.
Agent activity
56 hits · last 30 days
node
46
OpenAI (training)
1
Resources
pinecone-plugin-interface — pip install pinecone-plugin-interface · libregistry