The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
docs: update Azure OpenAI to v1 and langchain API to 0.1 (#18005)
Massimiliano Pronestic3c987dd70f3
diff --git a/docs/docs/integrations/llms/azure_openai.ipynb b/docs/docs/integrations/llms/azure_openai.ipynbindex 91abdcf3fe..98c8ac1835 100644--- a/docs/docs/integrations/llms/azure_openai.ipynb+++ b/docs/docs/integrations/llms/azure_openai.ipynb@@ -15,21 +15,19 @@"You can configure the `openai` package to use Azure OpenAI using environment variables. The following is for `bash`:\n","\n","```bash\n",- "# Set this to `azure`\n",- "export OPENAI_API_TYPE=azure\n",- "# The API version you want to use: set this to `2023-05-15` for the released version.\n",- "export OPENAI_API_VERSION=2023-05-15\n",+ "# The API version you want to use: set this to `2023-12-01-preview` for the released version.\n",+ "export OPENAI_API_VERSION=2023-12-01-preview\n","# The base URL for your Azure OpenAI resource. You can find this in the Azure portal under your Azure OpenAI resource.\n",- "export OPENAI_API_BASE=https://your-resource-name.openai.azure.com\n",+ "export AZURE_OPENAI_ENDPOINT=https://your-resource-name.openai.azure.com\n","# The API key for your Azure OpenAI resource. You can find this in the Azure portal under your Azure OpenAI resource.\n",- "export OPENAI_API_KEY=<your Azure OpenAI API key>\n",+ "export AZURE_OPENAI_API_KEY=<your Azure OpenAI API key>\n","```\n","\n","Alternatively, you can configure the API right within your running Python environment:\n","\n","```python\n","import os\n",- "os.environ[\"OPENAI_API_TYPE\"] = \"azure\"\n",+ "os.environ[\"OPENAI_API_VERSION\"] = \"2023-12-01-preview\"\n","```\n","\n","## Azure Active Directory Authentication\n",@@ -76,15 +74,18 @@"\n","_**Note**: These docs are for the Azure text completion models. Models like GPT-4 are chat models. They have a slightly different interface, and can be accessed via the `AzureChatOpenAI` class. For docs on Azure chat see [Azure Chat OpenAI documentation](/docs/integrations/chat/azure_chat_openai)._\n","\n",- "Let's say your deployment name is `text-davinci-002-prod`. In the `openai` Python API, you can specify this deployment with the `engine` parameter. For example:\n",+ "Let's say your deployment name is `gpt-35-turbo-instruct-prod`. In the `openai` Python API, you can specify this deployment with the `engine` parameter. For example:\n","\n","```python\n","import openai\n","\n",- "response = openai.Completion.create(\n",- " engine=\"text-davinci-002-prod\",\n",- " prompt=\"This is a test\",\n",- " max_tokens=5\n",+ "client = AzureOpenAI(\n",+ " api_version=\"2023-12-01-preview\",\n",+ ")\n",+ "\n",+ "response = client.completions.create(\n",+ " model=\"gpt-35-turbo-instruct-prod\",\n",+ " prompt=\"Test prompt\"\n",")\n","```\n"]@@ -103,22 +104,21 @@},{"cell_type": "code",- "execution_count": 3,+ "execution_count": 1,"id": "faacfa54","metadata": {},"outputs": [],"source": ["import os\n","\n",- "os.environ[\"OPENAI_API_TYPE\"] = \"azure\"\n",- "os.environ[\"OPENAI_API_VERSION\"] = \"2023-05-15\"\n",- "os.environ[\"OPENAI_API_BASE\"] = \"...\"\n",- "os.environ[\"OPENAI_API_KEY\"] = \"...\""+ "os.environ[\"OPENAI_API_VERSION\"] = \"2023-12-01-preview\"\n",+ "os.environ[\"AZURE_OPENAI_ENDPOINT\"] = \"...\"\n",+ "os.environ[\"AZURE_OPENAI_API_KEY\"] = \"...\""]},{"cell_type": "code",- "execution_count": 4,+ "execution_count": 2,"id": "8fad2a6e","metadata": {},"outputs": [],@@ -129,7 +129,7 @@},{"cell_type": "code",- "execution_count": 5,+ "execution_count": 3,"id": "8c80213a","metadata": {},"outputs": [],@@ -137,31 +137,28 @@"# Create an instance of Azure OpenAI\n","# Replace the deployment name with your own\n","llm = AzureOpenAI(\n",- " deployment_name=\"td2\",\n",- " model_name=\"gpt-3.5-turbo-instruct\",\n",+ " deployment_name=\"gpt-35-turbo-instruct-0914\",\n",")"]},{"cell_type": "code",- "execution_count": 6,+ "execution_count": 5,"id": "592dc404","metadata": {},"outputs": [{"data": {- "text/plain": [- "\"\\n\\nWhy couldn't the bicycle stand up by itself? Because it was...two tired!\""- ]+ "text/plain": "\" Why couldn't the bicycle stand up by itself?\\n\\nBecause it was two-tired!\""},- "execution_count": 6,+ "execution_count": 5,"metadata": {},"output_type": "execute_result"}],"source": ["# Run the LLM\n",- "llm(\"Tell me a joke\")"+ "llm.invoke(\"Tell me a joke\")"]},{@@ -174,7 +171,7 @@},{"cell_type": "code",- "execution_count": 4,+ "execution_count": 6,"id": "9c33fa19","metadata": {},"outputs": [@@ -182,8 +179,8 @@"name": "stdout","output_type": "stream","text": [- "\u001b[1mAzureOpenAI\u001b[0m\n",- "Params: {'deployment_name': 'text-davinci-002', 'model_name': 'text-davinci-002', 'temperature': 0.7, 'max_tokens': 256, 'top_p': 1, 'frequency_penalty': 0, 'presence_penalty': 0, 'n': 1, 'best_of': 1}\n"+ "\u001B[1mAzureOpenAI\u001B[0m\n",+ "Params: {'deployment_name': 'gpt-35-turbo-instruct-0914', 'model_name': 'gpt-3.5-turbo-instruct', 'temperature': 0.7, 'top_p': 1, 'frequency_penalty': 0, 'presence_penalty': 0, 'n': 1, 'logit_bias': {}, 'max_tokens': 256}\n"]}],