Skip to content

Commit 96db117

Browse files
committed
refactor
1 parent d3767e9 commit 96db117

File tree

14 files changed

+60
-142
lines changed

14 files changed

+60
-142
lines changed

docs/ai/quickstarts/includes/connect-prompt/semantic-kernel.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
```bash
2626
code .
2727
```
28+
2829
[!INCLUDE [create-ai-service](../create-ai-service.md)]
2930
3031
## Add the app code
@@ -54,4 +55,4 @@ The app uses the [`Microsoft.SemanticKernel`](https://www.nuget.org/packages/Mic
5455
5556
:::code language="csharp" source="../../snippets/prompt-completion/semantic-kernel/openai/program.cs" range="22-24":::
5657
57-
Customize the text content of the `benefits.md` file or the length of the summary to see the differences in the responses.
58+
Customize the text content of the `benefits.md` file or the length of the summary to see the differences in the responses.

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

Lines changed: 58 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,45 +12,86 @@ zone_pivot_groups: dotnet-ai-library
1212

1313
# Connect to and prompt an AI model using .NET
1414

15-
:::zone target="docs" pivot="microsoft-extensions-ai"
1615

1716
In this quickstart, learn how to create a .NET console chat app to connect to and prompt an OpenAI or Azure OpenAI model. The app uses the [`Microsoft.Extensions.AI`](https://www.nuget.org/packages/Microsoft.Extensions.AI) library so you can write code using AI abstractions rather than a specific SDK. AI abstractions enable you to change the underlying AI model with minimal code changes.
1817

18+
## Prerequisites
19+
20+
:::zone target="docs" pivot="openai"
21+
22+
[!INCLUDE [azure-openai-prereqs](includes/prerequisites-azure-openai.md)]
23+
1924
:::zone-end
2025

21-
:::zone target="docs" pivot="semantic-kernel"
26+
:::zone target="docs" pivot="azure-openai"
2227

23-
In this quickstart, learn how to create a .NET console chat app to connect to and prompt an OpenAI or Azure OpenAI model using [`Semantic Kernel`](/semantic-kernel/overview). Semantic Kernel is a lightweight, open-source development kit that lets you easily build AI agents and integrate the latest AI models into your C#, Python, or Java codebase. It serves as an efficient middleware that enables rapid delivery of enterprise-grade solutions.
28+
[!INCLUDE [openai-prereqs](includes/prerequisites-openai.md)]
2429

2530
:::zone-end
2631

27-
## Prerequisites
32+
## Clone the sample repository
2833

29-
# [Azure OpenAI](#tab/azure-openai)
34+
[!INCLUDE [clone-sample-repo](includes/clone-sample-repo.md)]
3035

31-
[!INCLUDE [azure-openai-prereqs](includes/prerequisites-azure-openai.md)]
36+
## Create the app
3237

33-
# [OpenAI](#tab/openai)
38+
1. In an empty directory on your computer, use the `dotnet new` command to create a new console app:
3439

35-
[!INCLUDE [openai-prereqs](includes/prerequisites-openai.md)]
40+
```dotnetcli
41+
dotnet new console -o ExtensionsAI
42+
```
3643
37-
---
44+
1. Change directory into the app folder:
3845
39-
## Clone the sample repository
46+
```dotnetcli
47+
cd ExtensionsAI
48+
```
4049
41-
[!INCLUDE [clone-sample-repo](includes/clone-sample-repo.md)]
50+
1. Install the required packages:
4251
43-
:::zone target="docs" pivot="microsoft-extensions-ai"
52+
```bash
53+
dotnet add package Microsoft.SemanticKernel
54+
dotnet add package Microsoft.Extensions.Configuration
55+
dotnet add package Microsoft.Extensions.Configuration.UserSecrets
56+
```
4457
45-
[!INCLUDE [extensions-ai](includes/connect-prompt/extensions-ai.md)]
58+
1. Open the app in Visual Studio code or your editor of choice
4659
47-
:::zone-end
60+
```bash
61+
code .
62+
```
4863
49-
:::zone target="docs" pivot="semantic-kernel"
64+
[!INCLUDE [create-ai-service](../create-ai-service.md)]
5065
51-
[!INCLUDE [semantic-kernel](includes/connect-prompt/semantic-kernel.md)]
66+
## Add the app code
5267
53-
:::zone-end
68+
The app uses the [`Microsoft.SemanticKernel`](https://www.nuget.org/packages/Microsoft.SemanticKernel) package to send and receive requests to the OpenAI service.
69+
70+
1. In the **Program.cs** file, add the following code to connect and authenticate to the AI model.
71+
72+
<!-- markdownlint-disable MD023 -->
73+
# [Azure OpenAI](#tab/azure-openai)
74+
75+
:::code language="csharp" source="./snippets/prompt-completion/semantic-kernel/azure-openai/program.cs" range="6-14":::
76+
77+
> [!NOTE]
78+
> `DefaultAzureCredential` searches for credentials from your local tooling. If you are not using the `azd` template to provision the Azure OpenAI resource, you'll need to assign the `Azure AI Developer` role to the account you used to sign-in to Visual Studio or the Azure CLI.
79+
80+
# [OpenAI](#tab/openai)
81+
82+
:::code language="csharp" source="./snippets/prompt-completion/semantic-kernel/openai/program.cs" range="5-13":::
83+
84+
---
85+
86+
1. Read the `benefits.md` file content and use it to create a `prompt` for model. The prompt instructs the model to summarize the file text content.
87+
88+
:::code language="csharp" source="./snippets/prompt-completion/semantic-kernel/openai/program.cs" range="15-20":::
89+
90+
1. Call the `InvokePromptAsync` function to send the `prompt` to the model to generate a response.
91+
92+
:::code language="csharp" source="./snippets/prompt-completion/semantic-kernel/openai/program.cs" range="22-24":::
93+
94+
Customize the text content of the `benefits.md` file or the length of the summary to see the differences in the responses.
5495
5596
## Clean up resources
5697
File renamed without changes.

docs/ai/quickstarts/snippets/prompt-completion/semantic-kernel/azure-openai/Program.cs

Lines changed: 0 additions & 25 deletions
This file was deleted.

docs/ai/quickstarts/snippets/prompt-completion/semantic-kernel/azure-openai/SemanticKernelAzureOpenAI.csproj

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)