File size: 482 Bytes
62d3b3c
 
 
097744c
62d3b3c
097744c
 
62d3b3c
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import os

from langchain_google_genai import GoogleGenerativeAIEmbeddings
from dotenv import load_dotenv

# load the environment variables
load_dotenv()
# Define the google api key
os.environ['GOOGLE_API_KEY'] = os.getenv('GOOGLE_API_KEY')
GOOGLE_API_KEY = os.environ.get("GOOGLE_API_KEY")

def text2vector(text):
    embeddings = GoogleGenerativeAIEmbeddings(model="models/embedding-001", google_api_key=GOOGLE_API_KEY)
    vector = embeddings.embed_query(text)
    return vector