Back to Mem0

Pinecone

embedchain/notebooks/pinecone.ipynb

2.0.11.1 KB
Original Source

Cookbook for using PineconeDB with Embedchain

Step-1: Install embedchain package

python
!pip install embedchain pinecone-client pinecone-text

Step-2: Set environment variables needed for Pinecone

You can find this env variable on your OpenAI dashboard and Pinecone dashboard.

python
import os
from embedchain import App

os.environ["OPENAI_API_KEY"] = "sk-xxx"
os.environ["PINECONE_API_KEY"] = "xxx"
os.environ["PINECONE_ENV"] = "xxx"

Step-3 Create embedchain app and define your config

python
app = App.from_config(config={
    "provider": "pinecone",
    "config": {
        "metric": "cosine",
        "vector_dimension": 768,
        "collection_name": "pc-index"
    }
})

Step-4: Add data sources to your app

python
app.add("https://www.forbes.com/profile/elon-musk")
python
while(True):
    question = input("Enter question: ")
    if question in ['q', 'exit', 'quit']:
        break
    answer = app.query(question)
    print(answer)