Files
mem0/notebooks/together.ipynb
T

5.6 KiB

Cookbook for using Cohere with Embedchain

Step-1: Install embedchain package

In [ ]:
!pip install embedchain[dataloaders,together]

You can find OPENAI_API_KEY on your OpenAI dashboard and TOGETHER_API_KEY key on your Together dashboard.

In [1]:
import os
from embedchain import Pipeline as App

os.environ["OPENAI_API_KEY"] = ""
os.environ["TOGETHER_API_KEY"] = ""

Step-3: Define your llm and embedding model config

In [2]:
config = """
llm:
  provider: together
  config:
    model: mistralai/Mixtral-8x7B-Instruct-v0.1
    temperature: 0.5
    max_tokens: 1000
"""

# Write the multi-line string to a YAML file
with open('together.yaml', 'w') as file:
    file.write(config)

Step-4 Create embedchain app based on the config

In [3]:
app = App.from_config(config_path="together.yaml")

Step-5: Add data sources to your app

In [4]:
app.add("https://www.forbes.com/profile/elon-musk")
Out [4]:
Inserting batches in chromadb: 100%|██████████| 1/1 [00:01<00:00,  1.16s/it]
Successfully saved https://www.forbes.com/profile/elon-musk (DataType.WEB_PAGE). New chunks count: 4
'8cf46026cabf9b05394a2658bd1fe890'
In [ ]:
while(True):
    question = input("Enter question: ")
    if question in ['q', 'exit', 'quit']:
        break
    answer = app.query(question)
    print(answer)
In [ ]: