Skip to content

Commit 6512975

Browse files
committed
changes
1 parent ccf23f3 commit 6512975

File tree

1 file changed

+34
-49
lines changed

1 file changed

+34
-49
lines changed

docs/ai/quickstarts/quickstart-openai-summarize-text.md

Lines changed: 34 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -28,86 +28,71 @@ In this quickstart, get started with AI by creating a .NET console chat app to c
2828

2929
---
3030

31-
## Get the sample project
32-
33-
[!INCLUDE [clone-sample-repo](includes/clone-sample-repo.md)]
34-
35-
## Try the hiking benefits sample
31+
## Create the app
3632

37-
The sample project includes completed apps you can run to connect to your AI model of choice:
38-
39-
# [OpenAI](#tab/openai)
40-
41-
1. From a terminal or command prompt, navigate to the `src\quickstarts\microsoft-extensions-ai\openai\01-HikeBenefitsSummary` directory.
42-
43-
1. Run the following commands to configure your OpenAI API key as a secret for the sample app:
33+
1. In an empty directory on your computer, use the `dotnet new` command to create a new console app:
4434

45-
```bash
46-
dotnet user-secrets init
47-
dotnet user-secrets set OpenAIKey <your-openai-key>
35+
```dotnetcli
36+
dotnet new console -o ExtensionsAI
4837
```
4938
50-
1. Use the `dotnet run` command to run the app:
39+
1. Change directory into the app folder:
5140
5241
```dotnetcli
53-
dotnet run
42+
cd ExtensionsAI
5443
```
5544
56-
# [Azure OpenAI](#tab/azure-openai)
57-
58-
1. From a terminal or command prompt, navigate to the `src\quickstarts\microsoft-extensions-ai\azure-openai\01-HikeBenefitsSummary` directory.
59-
60-
> [!NOTE]
61-
> The Azure OpenAI scenario assumes the use of `azd` to provision an Azure OpenAI resource and configure essential permissions. Your can also [provision an Azure OpenAI resource](/azure/ai-services/openai/how-to/create-resource) using another tool such as the Azure portal or Azure CLI.
62-
63-
1. Run the `azd up` command to provision the Azure OpenAI resource and configure the necessary permissions. The command may take a few minutes to finish.
45+
1. Install the required packages:
6446
6547
```bash
66-
azd up
48+
dotnet add package Azure.AI.OpenAI
49+
dotnet add package Microsoft.Extensions.AI.OpenAI
50+
dotnet add package Microsoft.Extensions.Configuration
51+
dotnet add package Microsoft.Extensions.Configuration.UserSecrets
6752
```
6853
69-
1. Use the `dotnet run` command to run the app:
70-
71-
```dotnetcli
72-
dotnet run
73-
```
54+
1. Open the app in Visual Studio code or your editor of choice
7455
75-
---
56+
```bash
57+
code.
58+
```
7659

77-
## Explore the code
60+
## Add the code
7861

7962
The app uses the [`Microsoft.Extensions.AI`](https://www.nuget.org/packages/Microsoft.Extensions.AI) package to send and receive requests to the OpenAI service.
8063

81-
The **Program.cs** file contains all of the app code. The first several lines of code set configuration values to connect and authenticate to the AI model.
64+
1. In the **Program.cs** file, add the following code to connect and authenticate to the AI model:
8265

83-
# [OpenAI](#tab/openai)
66+
# [OpenAI](#tab/openai)
8467

85-
:::code language="csharp" source="./snippets/prompt-completion/extensions-ai/openai/program.cs" range="5-7":::
68+
:::code language="csharp" source="./snippets/prompt-completion/extensions-ai/openai/program.cs" range="5-7":::
8669

87-
# [Azure OpenAI](#tab/azure-openai)
70+
# [Azure OpenAI](#tab/azure-openai)
8871

89-
> [!NOTE]
90-
> `DefaultAzureCredential` searches for credentials from your local environment and tooling. If you are not using the `azd` template to provision the Azure OpenAI resource, assign the `Azure AI Developer` role manually to the account you used to sign-in to Visual Studio or the Azure CLI.
72+
> [!NOTE]
73+
> `DefaultAzureCredential` searches for credentials from your local environment and tooling. If you are not using the `azd` template to provision the Azure OpenAI resource, assign the `Azure AI Developer` role manually to the account you used to sign-in to Visual Studio or the Azure CLI.
9174
92-
:::code language="csharp" source="./snippets/prompt-completion/extensions-ai/azure-openai/program.cs" range="6-8":::
75+
:::code language="csharp" source="./snippets/prompt-completion/extensions-ai/azure-openai/program.cs" range="6-8":::
9376

94-
---
77+
---
9578

96-
The following code obtains an `IChatClient` service configured to connect to the AI Model. The `OpenAI` and `Azure.AI.OpenAI` libraries implement types defined in the `Microsoft.Extensions.AI` library, which enables you to code using the `IChatClient` interface abstraction. This abstraction allows you to change the underlying AI provider to other services by updating only a few lines of code, such as Ollama or Azure Inference models.
79+
1. Add the following code to create an `IChatClient` service configured to connect to the AI Model:
9780

98-
# [OpenAI](#tab/openai)
81+
# [OpenAI](#tab/openai)
9982

100-
:::code language="csharp" source="./snippets/prompt-completion/extensions-ai/openai/program.cs" range="10-11":::
83+
:::code language="csharp" source="./snippets/prompt-completion/extensions-ai/openai/program.cs" range="10-11":::
10184

102-
# [Azure OpenAI](#tab/azure-openai)
85+
# [Azure OpenAI](#tab/azure-openai)
10386

104-
:::code language="csharp" source="./snippets/prompt-completion/extensions-ai/azure-openai/program.cs" range="10-12":::
87+
:::code language="csharp" source="./snippets/prompt-completion/extensions-ai/azure-openai/program.cs" range="10-12":::
10588

106-
---
89+
---
90+
91+
The `OpenAI` and `Azure.AI.OpenAI` libraries implement types defined in the `Microsoft.Extensions.AI` library, which enables you to code using the `IChatClient` interface abstraction. This abstraction allows you to change the underlying AI provider to other services by updating only a few lines of code, such as Ollama or Azure Inference models.
10792

108-
The `CompleteAsync` function sends the `prompt` to the model to generate a response. The `Microsoft.Extensions.AI` library enables this code to be agnostic towards a specific AI service because it uses an `IChatClient` abstraction rather than a platform-specific SDK implementation.
93+
1. Use the `CompleteAsync` function to send a `prompt` to the model to generate a response.
10994

110-
:::code language="csharp" source="./snippets/prompt-completion/extensions-ai/openai/program.cs" range="14-22":::
95+
:::code language="csharp" source="./snippets/prompt-completion/extensions-ai/openai/program.cs" range="14-22":::
11196

11297
Customize the text content of the `benefits.md` file or the length of the summary to see the differences in the responses.
11398

0 commit comments

Comments
 (0)