File size: 930 Bytes
af9408a
 
 
 
 
 
 
 
 
 
 
 
 
c2c7198
 
af9408a
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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