Skip to content

Examples and guides for using the OpenAI API

Update ad auth section

Christian Muertz934f4d863b36
diff --git a/examples/azure/completions.ipynb b/examples/azure/completions.ipynb
index b1cf30f9..da72f2f1 100644
--- a/examples/azure/completions.ipynb
+++ b/examples/azure/completions.ipynb
@@ -67,7 +67,7 @@
"metadata": {},
"source": [
"### (Optional) Setup: Microsoft Active Directory Authentication\n",
- "Let's now see how we can get a key via Microsoft Active Directory Authentication."
+ "Let's now see how we can get a key via Microsoft Active Directory Authentication. Uncomment the following code if you want to use Active Directory Authentication instead of keys from the portal."
]
},
{
@@ -76,15 +76,13 @@
"metadata": {},
"outputs": [],
"source": [
- "\"\"\"\n",
- "from azure.identity import DefaultAzureCredential\n",
+ "# from azure.identity import DefaultAzureCredential\n",
"\n",
- "default_credential = DefaultAzureCredential()\n",
- "token = default_credential.get_token(\"https://cognitiveservices.azure.com/.default\")\n",
+ "# default_credential = DefaultAzureCredential()\n",
+ "# token = default_credential.get_token(\"https://cognitiveservices.azure.com/.default\")\n",
"\n",
- "openai.api_type = 'azure_ad'\n",
- "openai.api_key = token.token\n",
- "\"\"\""
+ "# openai.api_type = 'azure_ad'\n",
+ "# openai.api_key = token.token"
]
},
{
@@ -191,6 +189,13 @@
"print(f'Deleting deployment: {deployment_id}')\n",
"openai.Deployment.delete(sid=deployment_id)"
]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": []
}
],
"metadata": {
diff --git a/examples/azure/embeddings.ipynb b/examples/azure/embeddings.ipynb
index f7729e72..cef6a0cc 100644
--- a/examples/azure/embeddings.ipynb
+++ b/examples/azure/embeddings.ipynb
@@ -72,7 +72,7 @@
"metadata": {},
"source": [
"### (Optional) Setup: Microsoft Active Directory Authentication\n",
- "Let's now see how we can get a key via Microsoft Active Directory Authentication."
+ "Let's now see how we can get a key via Microsoft Active Directory Authentication. Uncomment the following code if you want to use Active Directory Authentication instead of keys from the portal."
]
},
{
@@ -81,15 +81,13 @@
"metadata": {},
"outputs": [],
"source": [
- "\"\"\"\n",
- "from azure.identity import DefaultAzureCredential\n",
+ "# from azure.identity import DefaultAzureCredential\n",
"\n",
- "default_credential = DefaultAzureCredential()\n",
- "token = default_credential.get_token(\"https://cognitiveservices.azure.com/.default\")\n",
+ "# default_credential = DefaultAzureCredential()\n",
+ "# token = default_credential.get_token(\"https://cognitiveservices.azure.com/.default\")\n",
"\n",
- "openai.api_type = 'azure_ad'\n",
- "openai.api_key = token.token\n",
- "\"\"\""
+ "# openai.api_type = 'azure_ad'\n",
+ "# openai.api_key = token.token"
]
},
{
diff --git a/examples/azure/finetuning.ipynb b/examples/azure/finetuning.ipynb
index 3f6ed662..434901d8 100644
--- a/examples/azure/finetuning.ipynb
+++ b/examples/azure/finetuning.ipynb
@@ -68,7 +68,7 @@
"metadata": {},
"source": [
"### (Optional) Setup: Microsoft Active Directory Authentication\n",
- "Let's now see how we can get a key via Microsoft Active Directory Authentication."
+ "Let's now see how we can get a key via Microsoft Active Directory Authentication. Uncomment the following code if you want to use Active Directory Authentication instead of keys from the portal."
]
},
{
@@ -77,15 +77,13 @@
"metadata": {},
"outputs": [],
"source": [
- "\"\"\"\n",
- "from azure.identity import DefaultAzureCredential\n",
+ "# from azure.identity import DefaultAzureCredential\n",
"\n",
- "default_credential = DefaultAzureCredential()\n",
- "token = default_credential.get_token(\"https://cognitiveservices.azure.com/.default\")\n",
+ "# default_credential = DefaultAzureCredential()\n",
+ "# token = default_credential.get_token(\"https://cognitiveservices.azure.com/.default\")\n",
"\n",
- "openai.api_type = 'azure_ad'\n",
- "openai.api_key = token.token\n",
- "\"\"\""
+ "# openai.api_type = 'azure_ad'\n",
+ "# openai.api_key = token.token"
]
},
{