Pinecone Assistant Plugin

3.0.3 · active · verified Mon Apr 06

The `pinecone-plugin-assistant` library provides an interface for interacting with Pinecone's Assistant APIs, enabling users to create, manage, and chat with AI assistants. As of Pinecone Python SDK v7.0.0, the functionalities provided by this plugin are bundled directly within the main `pinecone` package. It is currently at version 3.0.3 and is actively maintained as part of the broader Pinecone ecosystem, with its release cadence tied to the main Pinecone SDK releases.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the Pinecone client, create a new AI assistant, send a chat message to it, and receive a response. It includes basic error handling and cleanup. Ensure your Pinecone API key is set as an environment variable (`PINECONE_API_KEY`).

import os
from pinecone import Pinecone
from pinecone_plugins.assistant.models.chat import Message

# Ensure PINECONE_API_KEY is set as an environment variable
api_key = os.environ.get('PINECONE_API_KEY', '')
if not api_key:
    raise ValueError("PINECONE_API_KEY environment variable not set.")

pc = Pinecone(api_key=api_key)

assistant_name = "my-test-assistant"

try:
    # Create an assistant
    assistant = pc.assistant.create_assistant(
        assistant_name=assistant_name,
        instructions="Answer questions concisely."
    )
    print(f"Assistant '{assistant.name}' created.")

    # Example chat interaction
    user_message = Message(content="What is the capital of France?")
    response = assistant.chat_completions(messages=[user_message])

    print("Assistant's response:")
    for choice in response.choices:
        print(choice.message.content)

except Exception as e:
    print(f"An error occurred: {e}")
finally:
    # Clean up (optional): delete the assistant
    try:
        pc.assistant.delete_assistant(assistant_name=assistant_name)
        print(f"Assistant '{assistant_name}' deleted.")
    except Exception as e:
        print(f"Failed to delete assistant: {e}")

view raw JSON →