Back to Mem0

Anthropic

embedchain/notebooks/anthropic.ipynb

2.0.11.1 KB
Original Source

Cookbook for using Anthropic with Embedchain

Step-1: Install embedchain package

python
!pip install embedchain

You can find OPENAI_API_KEY on your OpenAI dashboard and ANTHROPIC_API_KEY on your Anthropic dashboard.

python
import os
from embedchain import App

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

Step-3: Create embedchain app and define your config

python
app = App.from_config(config={
    "provider": "anthropic",
    "config": {
        "model": "claude-instant-1",
        "temperature": 0.5,
        "top_p": 1,
        "stream": False
    }
})

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)