testbot_v4 / embedding_loader.py
soyleyicicem's picture
Update embedding_loader.py
c2c7198 verified
raw
history blame contribute delete
930 Bytes
from langchain_huggingface import HuggingFaceEmbeddings
from langchain_openai import AzureOpenAIEmbeddings
import openai
import os
def import_embedding():
# embedding_name = None
# myEmbeddingModel = HuggingFaceEmbeddings(
# model_name = embedding_name,
# model_kwargs = {'device':'cuda'},
# encode_kwargs={'normalize_embeddings':True})
AZURE_OPENAI_KEY = os.getenv('azure_api')
os.environ['AZURE_OPENAI_KEY'] = AZURE_OPENAI_KEY
openai.api_version = "2023-05-15" # change it with your own version
openai.azure_endpoint = os.getenv('azure_endpoint_embed')
embedding_name = "embedding3large" # deployment name on Azure OPENAI Studio
myEmbeddingModel = AzureOpenAIEmbeddings(azure_deployment=embedding_name,
azure_endpoint = openai.azure_endpoint,
api_key=AZURE_OPENAI_KEY,
api_version=openai.api_version)
return myEmbeddingModel