mirror of
https://github.com/langchain-ai/langchain.git
synced 2026-10-11 20:35:14 +03:00
# Documentation for Azure OpenAI embeddings model - OPENAI_API_VERSION environment variable is needed for the endpoint - The constructor does not work with model, it works with deployment. I fixed it in the notebook. (This is my first contribution) ## Who can review? @hwchase17 @agola Co-authored-by: Harrison Chase <hw.chase.17@gmail.com>
2.3 KiB
2.3 KiB
In [ ]:
# set the environment variables needed for openai package to know to reach out to azure
import os
os.environ["OPENAI_API_TYPE"] = "azure"
os.environ["OPENAI_API_BASE"] = "https://<your-endpoint.openai.azure.com/"
os.environ["OPENAI_API_KEY"] = "your AzureOpenAI key"
os.environ["OPENAI_API_VERSION"] = "2023-03-15-preview"In [ ]:
from langchain.embeddings import OpenAIEmbeddings
embeddings = OpenAIEmbeddings(deployment="your-embeddings-deployment-name")In [ ]:
text = "This is a test document."In [ ]:
query_result = embeddings.embed_query(text)In [ ]:
doc_result = embeddings.embed_documents([text])In [ ]: