diff --git a/cookbook/openai_v1_cookbook.ipynb b/cookbook/openai_v1_cookbook.ipynb index 9a69527af20..2b1c1deabdb 100644 --- a/cookbook/openai_v1_cookbook.ipynb +++ b/cookbook/openai_v1_cookbook.ipynb @@ -17,7 +17,7 @@ "metadata": {}, "outputs": [], "source": [ - "!pip install -U openai \"langchain>=0.0.331rc2\" langchain-experimental" + "!pip install -U openai \"langchain>=0.0.331rc3\" langchain-experimental" ] }, { @@ -389,6 +389,35 @@ ")\n", "print(output.llm_output)" ] + }, + { + "cell_type": "markdown", + "id": "aa6565be-985d-4127-848e-c3bca9d7b434", + "metadata": {}, + "source": [ + "## Breaking changes to Azure classes\n", + "\n", + "OpenAI V1 rewrote their clients and separated Azure and OpenAI clients. This has led to some changes in LangChain interfaces when using OpenAI V1.\n", + "\n", + "BREAKING CHANGES:\n", + "- To use Azure embeddings with OpenAI V1, you'll need to use the new `AzureOpenAIEmbeddings` instead of the existing `OpenAIEmbeddings`. `OpenAIEmbeddings` continue to work when using Azure with `openai<1`.\n", + "```python\n", + "from langchain.embeddings import AzureOpenAIEmbeddings\n", + "```\n", + "\n", + "\n", + "RECOMMENDED CHANGES:\n", + "- When using AzureChatOpenAI, if passing in an Azure endpoint (eg https://example-resource.azure.openai.com/) this should be specified via the `azure_endpoint` parameter or the `AZURE_OPENAI_ENDPOINT`. We're maintaining backwards compatibility for now with specifying this via `openai_api_base`/`base_url` or env var `OPENAI_API_BASE` but this shouldn't be relied upon.\n", + "- When using Azure chat or embedding models, pass in API keys either via `openai_api_key` parameter or `AZURE_OPENAI_API_KEY` parameter. We're maintaining backwards compatibility for now with specifying this via `OPENAI_API_KEY` but this shouldn't be relied upon." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "52b48493-e4fe-4ab9-97cd-e65bf3996e30", + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { diff --git a/libs/experimental/pyproject.toml b/libs/experimental/pyproject.toml index a596444e9ba..18b61ab8dea 100644 --- a/libs/experimental/pyproject.toml +++ b/libs/experimental/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "langchain-experimental" -version = "0.0.38" +version = "0.0.39" description = "Building applications with LLMs through composability" authors = [] license = "MIT" diff --git a/libs/langchain/langchain/chat_models/azure_openai.py b/libs/langchain/langchain/chat_models/azure_openai.py index f7a2bcd61a3..c2a24d578a5 100644 --- a/libs/langchain/langchain/chat_models/azure_openai.py +++ b/libs/langchain/langchain/chat_models/azure_openai.py @@ -57,6 +57,8 @@ class AzureChatOpenAI(ChatOpenAI): azure_endpoint: Union[str, None] = None """Your Azure endpoint, including the resource. + Automatically inferred from env var `AZURE_OPENAI_ENDPOINT` if not provided. + Example: `https://example-resource.azure.openai.com/` """ deployment_name: Union[str, None] = Field(default=None, alias="azure_deployment") diff --git a/libs/langchain/langchain/embeddings/azure_openai.py b/libs/langchain/langchain/embeddings/azure_openai.py index f9a233e55be..27e34e50b83 100644 --- a/libs/langchain/langchain/embeddings/azure_openai.py +++ b/libs/langchain/langchain/embeddings/azure_openai.py @@ -17,6 +17,8 @@ class AzureOpenAIEmbeddings(OpenAIEmbeddings): azure_endpoint: Union[str, None] = None """Your Azure endpoint, including the resource. + Automatically inferred from env var `AZURE_OPENAI_ENDPOINT` if not provided. + Example: `https://example-resource.azure.openai.com/` """ azure_deployment: Optional[str] = None diff --git a/libs/langchain/pyproject.toml b/libs/langchain/pyproject.toml index 639db56239d..572bdfd7abf 100644 --- a/libs/langchain/pyproject.toml +++ b/libs/langchain/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "langchain" -version = "0.0.331rc2" +version = "0.0.331rc3" description = "Building applications with LLMs through composability" authors = [] license = "MIT"