Skip to content

Commit 6bc71d0

Browse files
Merge pull request #226175 from eric-urban/eur/openai-qs
OpenAI QS refresh
2 parents 760c845 + fd0f399 commit 6bc71d0

File tree

10 files changed

+84
-75
lines changed

10 files changed

+84
-75
lines changed

articles/cognitive-services/openai/how-to/create-resource.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ manager: nitinme
77
ms.service: cognitive-services
88
ms.subservice: openai
99
ms.topic: how-to
10-
ms.date: 06/30/2022
10+
ms.date: 02/02/2023
1111
zone_pivot_groups: openai-create-resource
1212
author: ChrisHMSFT
1313
ms.author: chrhoder
@@ -16,17 +16,17 @@ recommendations: false
1616

1717
# Create a resource and deploy a model using Azure OpenAI
1818

19-
Use this article to get started with Azure OpenAI with step-by-step instructions to create a resource and deploy a model. While the steps for resource creation and model deployment can be completed in a few minutes, the actual deployment process itself can take more than hour. It is recommended to create your resource, start your deployment, and then check back in on your deployment later rather than actively waiting for the deployment to complete.
19+
Use this article to get started with Azure OpenAI with step-by-step instructions to create a resource and deploy a model. While the steps for resource creation and model deployment can be completed in a few minutes, the actual deployment process itself can take more than hour. You can create your resource, start your deployment, and then check back in on your deployment later rather than actively waiting for the deployment to complete.
2020

2121
::: zone pivot="web-portal"
2222

23-
[!INCLUDE [Studio quickstart](../includes/create-resource-portal.md)]
23+
[!INCLUDE [Studio resource](../includes/create-resource-portal.md)]
2424

2525
::: zone-end
2626

2727
::: zone pivot="cli"
2828

29-
[!INCLUDE [Python SDK quickstart](../includes/create-resource-cli.md)]
29+
[!INCLUDE [Azure CLI resource](../includes/create-resource-cli.md)]
3030

3131
::: zone-end
3232

articles/cognitive-services/openai/includes/create-resource-cli.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ ms.subservice: openai
99
ms.topic: include
1010
ms.date: 6/30/2022
1111
keywords:
12-
1312
---
1413

1514
## Prerequisites

articles/cognitive-services/openai/includes/create-resource-portal.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ manager: nitinme
77
ms.service: cognitive-services
88
ms.subservice: openai
99
ms.topic: include
10-
ms.date: 06/30/2022
10+
ms.date: 02/02/2023
1111
keywords:
1212
---
1313

@@ -22,7 +22,7 @@ keywords:
2222

2323
Resources in Azure can be created several different ways:
2424

25-
- Within the Azure portal
25+
- Within the [Azure portal](https://portal.azure.com/?microsoft_azure_marketplace_ItemHideKey=microsoft_openai_tip#create/Microsoft.CognitiveServicesOpenAI)
2626
- Using the REST APIs, Azure CLI, PowerShell or client libraries
2727
- Via ARM templates
2828

@@ -43,14 +43,21 @@ This guide walks you through the Azure portal creation experience.
4343

4444
## Deploy a model
4545

46-
Before you can generate text or inference, you need to deploy a model. This is done by selecting **create new deployment** on the **deployments** page. From here, you can select from one of our many available models. For getting started, we recommend `text-davinci-002` for users in South Central and `text-davinci-001` for users in West Europe (text-davinci-002 is not available in this region). You can do this in the Azure OpenAI Studio.
46+
Before you can generate text or inference, you need to deploy a model. You can select from one of several available models in the Azure OpenAI Studio.
4747

48-
1. Go to the [Azure OpenAI Studio](https://oai.azure.com)
48+
Davinci is the most capable model family and can perform any task the other models can perform and often with less instruction. For applications requiring a lot of understanding of the content, like summarization for a specific audience and creative content generation, Davinci is going to produce the best results.
4949

50-
1. Login with the resource you want to use
50+
To deploy a model, follow these steps:
5151

52-
1. Select the **Go to Deployments** button under **Manage deployments in your resource** to navigate to the **Deployments** page
52+
1. Sign in to the [Azure OpenAI Studio](https://oai.azure.com).
53+
1. Select the subscription and OpenAI resource to work with.
54+
1. Select **Manage deployments in your resource** > **Go to Deployments** under **Manage your deployments and models**. You might first need to scroll down on the landing page.
5355

5456
:::image type="content" source="../media/create-resource/deployment.png" alt-text="Screenshot of the Azure OpenAI Studio page with the 'Go to Deployments' button highlighted." lightbox="../media/create-resource/deployment.png":::
5557

56-
1. Create a new deployment called `text-davinci-002` and choose the `text-davinci-002` model from the drop-down.
58+
1. Select **Create new deployment** from the **Management** > **Deployments** page.
59+
1. Select a model from the drop-down. For getting started in the East US region, we recommend the `text-davinci-003` model. In other regions you should start with the `text-davinci-002` model. Some models are not available in all regions. For a list of available models per region, see [Model Summary table and region availability](../concepts/models.md#model-summary-table-and-region-availability).
60+
1. Enter a model name to help you identify the model. Choose a name carefully. The model name will be used as the deployment name via OpenAI client libraries and API.
61+
1. Select **Create** to deploy the model.
62+
63+
The deployments table displays a new entry that corresponds to this newly created model. Your deployment status will move to succeeded when the deployment is complete and ready for use.

articles/cognitive-services/openai/includes/python.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ manager: nitinme
77
ms.service: cognitive-services
88
ms.subservice: openai
99
ms.topic: include
10-
ms.date: 12/14/2022
10+
ms.date: 02/02/2023
1111
keywords:
1212
---
1313

@@ -21,18 +21,18 @@ keywords:
2121
Currently, access to this service is granted only by application. You can apply for access to the Azure OpenAI service by completing the form at <a href="https://aka.ms/oai/access" target="_blank">https://aka.ms/oai/access</a>. Open an issue on this repo to contact us if you have an issue.
2222
- <a href="https://www.python.org/" target="_blank">Python 3.7.1 or later version</a>
2323
- The following Python libraries: os, requests, json
24-
- An Azure OpenAI Service resource with a model deployed. If you don't have a resource/model the process is documented in our [resource deployment guide](../how-to/create-resource.md)
24+
- An Azure OpenAI Service resource with a model deployed. For more information about model deployment, see the [resource deployment guide](../how-to/create-resource.md).
2525

2626
## Set up
2727

28-
1. Install the client library. You can install the client library with:
28+
Install the OpenAI Python client library with:
2929

3030
```console
3131
pip install openai
3232
```
3333

3434
> [!NOTE]
35-
> This library is maintained by OpenAI and is currently a preview release. Use the [version.py commit history](https://github.com/openai/openai-python/commits/main/openai/version.py) to track the latest updates to the library.
35+
> This library is maintained by OpenAI and is currently in preview. Refer to the [release history](https://github.com/openai/openai-python/releases) or the [version.py commit history](https://github.com/openai/openai-python/commits/main/openai/version.py) to track the latest updates to the library.
3636
3737
## Retrieve key and endpoint
3838

@@ -42,7 +42,7 @@ To successfully make a call against the Azure OpenAI service, you'll need the fo
4242
|--------------------------|-------------|
4343
| `ENDPOINT` | This value can be found in the **Keys & Endpoint** section when examining your resource from the Azure portal. Alternatively, you can find the value in the **Azure OpenAI Studio** > **Playground** > **Code View**. An example endpoint is: `https://docs-test-001.openai.azure.com/`.|
4444
| `API-KEY` | This value can be found in the **Keys & Endpoint** section when examining your resource from the Azure portal. You can use either `KEY1` or `KEY2`.|
45-
| `DEPLOYMENT-NAME` | This will correspond to the custom name you chose for your deployment when you deployed a model. This value can be found under **Resource Management** > **Deployments** in the Azure portal or alternatively under **Management** > **Deployments** in Azure OpenAI Studio.|
45+
| `DEPLOYMENT-NAME` | This value will correspond to the custom name you chose for your deployment when you deployed a model. This value can be found under **Resource Management** > **Deployments** in the Azure portal or alternatively under **Management** > **Deployments** in Azure OpenAI Studio.|
4646

4747
Go to your resource in the Azure portal. The **Endpoint and Keys** can be found in the **Resource Management** section. Copy your endpoint and access key as you'll need both for authenticating your API calls. You can use either `KEY1` or `KEY2`. Always having two keys allows you to securely rotate and regenerate keys without causing a service disruption.
4848

@@ -52,7 +52,7 @@ Go to your resource in the Azure portal. The **Endpoint and Keys** can be found
5252

5353
1. Create a new Python file called quickstart.py. Then open it up in your preferred editor or IDE.
5454

55-
2. Replace the contents of quickstart.py with the following code. Modify the code to add your key, endpoint, and deployment name:
55+
2. Replace the contents of quickstart.py with the following code. Modify the code to add your key, endpoint, and deployment name:
5656

5757
```python
5858
import os
@@ -65,27 +65,29 @@ Go to your resource in the Azure portal. The **Endpoint and Keys** can be found
6565
openai.api_type = 'azure'
6666
openai.api_version = '2022-12-01' # this may change in the future
6767

68-
deployment_id='REPLACE_WITH_YOUR_DEPLOYMENT_NAME' #This will correspond to the custom name you chose for your deployment when you deployed a model.
68+
deployment_name='REPLACE_WITH_YOUR_DEPLOYMENT_NAME' #This will correspond to the custom name you chose for your deployment when you deployed a model.
6969

7070
# Send a completion call to generate an answer
7171
print('Sending a test completion job')
7272
start_phrase = 'Write a tagline for an ice cream shop. '
73-
response = openai.Completion.create(engine=deployment_id, prompt=start_phrase, max_tokens=10)
73+
response = openai.Completion.create(engine=deployment_name, prompt=start_phrase, max_tokens=10)
7474
text = response['choices'][0]['text'].replace('\n', '').replace(' .', '.').strip()
7575
print(start_phrase+text)
7676
```
7777

78-
> [!IMPORTANT]
79-
> Remember to remove the key from your code when you're done, and never post it publicly. For production, use a secure way of storing and accessing your credentials like [Azure Key Vault](../../../key-vault/general/overview.md). See the Cognitive Services [security](../../cognitive-services-security.md) article for more information.
78+
> [!IMPORTANT]
79+
> Remember to remove the key from your code when you're done, and never post it publicly. For production, use a secure way of storing and accessing your credentials like [Azure Key Vault](../../../key-vault/general/overview.md). See the Cognitive Services [security](../../cognitive-services-security.md) article for more information.
8080

81-
1. Run the application with the `python` command on your quickstart file
81+
1. Run the application with the `python` command on your quickstart file:
8282

8383
```console
8484
python quickstart.py
8585
```
8686

8787
## Output
8888

89+
The output will include response text following the `Write a tagline for an ice cream shop.` prompt. The Azure OpenAI Service returned `The coldest ice cream in town!` in this example.
90+
8991
```console
9092
Sending a test completion job
9193
Write a tagline for an ice cream shop. The coldest ice cream in town!
@@ -95,7 +97,7 @@ Run the code a few more times to see what other types of responses you get as th
9597

9698
### Understanding your results
9799

98-
Since our example of `Write a tagline for an ice cream shop.` provides very little context, it's normal for the model to not always return expected results. You can adjust the maximum number of tokens if the response seems unexpected or truncated.
100+
Since our example of `Write a tagline for an ice cream shop.` provides little context, it's normal for the model to not always return expected results. You can adjust the maximum number of tokens if the response seems unexpected or truncated.
99101

100102
The Azure OpenAI Service also performs content moderation on the prompt inputs and generated outputs. The prompts or responses may be filtered if harmful content is detected. For more information, see the [content filter](../concepts/content-filter.md) article.
101103

articles/cognitive-services/openai/includes/rest.md

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ manager: nitinme
77
ms.service: cognitive-services
88
ms.subservice: openai
99
ms.topic: include
10-
ms.date: 12/14/2022
10+
ms.date: 02/02/2023
1111
keywords:
1212
---
1313

@@ -19,7 +19,7 @@ keywords:
1919
Currently, access to this service is granted only by application. You can apply for access to the Azure OpenAI service by completing the form at <a href="https://aka.ms/oai/access" target="_blank">https://aka.ms/oai/access</a>. Open an issue on this repo to contact us if you have an issue.
2020
- <a href="https://www.python.org/" target="_blank">Python 3.7.1 or later version</a>
2121
- The following Python libraries: os, requests, json
22-
- An Azure OpenAI Service resource with a model deployed. If you don't have a resource/model the process is documented in our [resource deployment guide](../how-to/create-resource.md)
22+
- An Azure OpenAI Service resource with a model deployed. For more information about model deployment, see the [resource deployment guide](../how-to/create-resource.md).
2323

2424
## Retrieve key and endpoint
2525

@@ -29,7 +29,7 @@ To successfully make a call against the Azure OpenAI service, you'll need the fo
2929
|--------------------------|-------------|
3030
| `ENDPOINT` | This value can be found in the **Keys & Endpoint** section when examining your resource from the Azure portal. Alternatively, you can find the value in the **Azure OpenAI Studio** > **Playground** > **Code View**. An example endpoint is: `https://docs-test-001.openai.azure.com/`.|
3131
| `API-KEY` | This value can be found in the **Keys & Endpoint** section when examining your resource from the Azure portal. You can use either `KEY1` or `KEY2`.|
32-
| `DEPLOYMENT-NAME` | This will correspond to the custom name you chose for your deployment when you deployed a model. This value can be found under **Resource Management** > **Deployments** in the Azure portal or alternatively under **Management** > **Deployments** in Azure OpenAI Studio.|
32+
| `DEPLOYMENT-NAME` | This value will correspond to the custom name you chose for your deployment when you deployed a model. This value can be found under **Resource Management** > **Deployments** in the Azure portal or alternatively under **Management** > **Deployments** in Azure OpenAI Studio.|
3333

3434
Go to your resource in the Azure portal. The **Endpoint and Keys** can be found in the **Resource Management** section. Copy your endpoint and access key as you'll need both for authenticating your API calls. You can use either `KEY1` or `KEY2`. Always having two keys allows you to securely rotate and regenerate keys without causing a service disruption.
3535

@@ -46,19 +46,19 @@ Create a new Python file called quickstart.py. Then open it up in your preferred
4646
import requests
4747
import json
4848

49-
apiKey = "REPLACE_WITH_YOUR_API_KEY_HERE"
49+
api_key = "REPLACE_WITH_YOUR_API_KEY_HERE"
5050
base_url = "REPLACE_WITH_YOUR_ENDPOINT_HERE"
51-
deploymentName ="REPLACE_WITH_YOUR_DEPLOYMENT_NAME_HERE"
51+
deployment_name ="REPLACE_WITH_YOUR_DEPLOYMENT_NAME_HERE"
5252

53-
url = base_url + "/openai/deployments/" + deploymentName + "/completions?api-version=2022-12-01"
53+
url = base_url + "/openai/deployments/" + deployment_name + "/completions?api-version=2022-12-01"
5454
prompt = "Once upon a time"
5555
payload = {
5656
"prompt":prompt
5757
}
5858

5959
r = requests.post(url,
6060
headers={
61-
"api-key": apiKey,
61+
"api-key": api_key,
6262
"Content-Type": "application/json"
6363
},
6464
json = payload
@@ -70,10 +70,10 @@ Create a new Python file called quickstart.py. Then open it up in your preferred
7070
print(formatted_response)
7171
```
7272

73-
> [!IMPORTANT]
74-
> Remember to remove the key from your code when you're done, and never post it publicly. For production, use a secure way of storing and accessing your credentials. For example, [Azure Key Vault](../../../key-vault/general/overview.md).
73+
> [!IMPORTANT]
74+
> Remember to remove the key from your code when you're done, and never post it publicly. For production, use a secure way of storing and accessing your credentials. For example, [Azure Key Vault](../../../key-vault/general/overview.md).
7575

76-
1. Run the application with the `python` command on your quickstart file
76+
1. Run the application with the `python` command on your quickstart file:
7777

7878
```console
7979
python quickstart.py
@@ -84,20 +84,25 @@ Create a new Python file called quickstart.py. Then open it up in your preferred
8484
The output from the completions API will look as follows.
8585

8686
```json
87-
{
88-
"id": "id of your call",
87+
{
88+
"id": "ID of your call",
8989
"object": "text_completion",
90-
"created": 1589478378,
91-
"model": "model used",
90+
"created": 1675444965,
91+
"model": "text-davinci-002",
9292
"choices": [
9393
{
94-
"text": " there was a girl who",
95-
"index": 0,
96-
"logprobs": null,
97-
"finish_reason": "length"
94+
"text": " there lived in a little village a woman who was known as the meanest",
95+
"index": 0,
96+
"finish_reason": "length",
97+
"logprobs": null
9898
}
99-
]
99+
],
100+
"usage": {
101+
"completion_tokens": 16,
102+
"prompt_tokens": 3,
103+
"total_tokens": 19
100104
}
105+
}
101106
```
102107

103108
The Azure OpenAI Service also performs content moderation on the prompt inputs and generated outputs. The prompts or responses may be filtered if harmful content is detected. For more information, see the [content filter](../concepts/content-filter.md) article.

0 commit comments

Comments
 (0)