Adjust finetuning setup section

This commit is contained in:
Christian Muertz 2022-12-19 10:40:02 +01:00
parent ca628a18be
commit 3708c28834

View File

@ -24,7 +24,7 @@
"metadata": {}, "metadata": {},
"source": [ "source": [
"## Setup\n", "## Setup\n",
"In the following section the endpoint and key need to be set up of the next sections to work.<br> Please go to https://portal.azure.com, find your resource and then under \"Resource Management\" -> \"Keys and Endpoints\" look for the \"Endpoint\" value and one of the Keys. They will act as api_base and api_key in the code below." "For the following sections to work properly we first have to setup some things. Let's start with the `api_type`, `api_base` and `api_version`. To find your `api_base` go to https://portal.azure.com, find your resource and then under \"Resource Management\" -> \"Keys and Endpoints\" look for the \"Endpoint\" value."
] ]
}, },
{ {
@ -33,19 +33,43 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"openai.api_key = '' # Please add your api key here\n",
"openai.api_base = '' # Please add your endpoint here\n",
"\n",
"openai.api_type = 'azure'\n", "openai.api_type = 'azure'\n",
"openai.api_version = '2022-12-01'" "openai.api_version = '2022-12-01'\n",
"\n",
"openai.api_base = '' # Please add your endpoint here"
] ]
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"## Microsoft Active Directory Authentication\n", "We next have to setup the `api_key`. We can either get the key from the portal or we can get it through Microsoft Active Directory Authentication."
"Instead of key based authentication, you can use Active Directory to authenticate using credential tokens. Uncomment the next code section to use credential based authentication:" ]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Setup: Portal\n",
"Let's first look at getting the key from the portal. Go to https://portal.azure.com, find your resource and then under \"Resource Management\" -> \"Keys and Endpoints\" look for one of the \"Keys\" values."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"openai.api_key = '' # Please add your api key here"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"### (Optional) Setup: Microsoft Active Directory Authentication\n",
"Let's now see how we can get a key via Microsoft Active Directory Authentication."
] ]
}, },
{ {
@ -60,12 +84,7 @@
"default_credential = DefaultAzureCredential()\n", "default_credential = DefaultAzureCredential()\n",
"token = default_credential.get_token(\"https://cognitiveservices.azure.com/.default\")\n", "token = default_credential.get_token(\"https://cognitiveservices.azure.com/.default\")\n",
"\n", "\n",
"openai.api_type = 'azure_ad'\n",
"openai.api_key = token.token\n", "openai.api_key = token.token\n",
"openai.api_version = '2022-03-01-preview' # this may change in the future\n",
"\n",
"\n",
"openai.api_base = '' # Please add your endpoint here\n",
"\"\"\"" "\"\"\""
] ]
}, },
@ -450,7 +469,7 @@
], ],
"metadata": { "metadata": {
"kernelspec": { "kernelspec": {
"display_name": "Python 3 (ipykernel)", "display_name": "Python 3",
"language": "python", "language": "python",
"name": "python3" "name": "python3"
}, },
@ -464,11 +483,11 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.8.10" "version": "3.10.8"
}, },
"vscode": { "vscode": {
"interpreter": { "interpreter": {
"hash": "cb9817b186a29e4e9713184d901f26c1ee05ad25243d878baff7f31bb1fef480" "hash": "3a5103089ab7e7c666b279eeded403fcec76de49a40685dbdfe9f9c78ad97c17"
} }
} }
}, },