Back to Mem0

Vertex Ai

embedchain/notebooks/vertex_ai.ipynb

2.0.11.2 KB
Original Source

Cookbook for using VertexAI with Embedchain

Step-1: Install embedchain package

python
!pip install embedchain[vertexai]

You can find OPENAI_API_KEY on your OpenAI dashboard.

python
import os
from embedchain import App

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

Step-3 Create embedchain app and define your config

python
app = App.from_config(config={
    "llm": {
        "provider": "vertexai",
        "config": {
            "model": "chat-bison",
            "temperature": 0.5,
            "max_tokens": 1000,
            "stream": False
        }
    },
    "embedder": {
        "provider": "vertexai",
        "config": {
            "model": "textembedding-gecko"
        }
    }
})

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)