Files
mem0/embedchain/notebooks/opensearch.ipynb

3.4 KiB

Cookbook for using OpenSearchDB with Embedchain

Step-1: Install embedchain package

In [ ]:
!pip install embedchain[opensearch]

Step-2: Set OpenAI environment variables and install the dependencies.

You can find this env variable on your OpenAI dashboard. Now lets install the dependencies needed for Opensearch.

In [ ]:
import os
from embedchain import App

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

Step-3 Create embedchain app and define your config

In [ ]:
app = App.from_config(config={
    "provider": "opensearch",
    "config": {
        "opensearch_url": "your-opensearch-url.com",
        "http_auth": ["admin", "admin"],
        "vector_dimension": 1536,
        "collection_name": "my-app",
        "use_ssl": False,
        "verify_certs": False
    }
})

Step-4: Add data sources to your app

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