Skip to content

Commit 295d14d

Browse files
committed
removing code sample
1 parent be4b7ad commit 295d14d

File tree

1 file changed

+0
-69
lines changed

1 file changed

+0
-69
lines changed

articles/ai-services/openai/includes/use-your-data-dotnet.md

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ ms.date: 01/09/2025
1414

1515
From the project directory, open the *Program.cs* file and replace its contents with the following code:
1616

17-
### Without response streaming
18-
1917
```csharp
2018
using System;
2119
using Azure.AI.OpenAI;
@@ -90,70 +88,3 @@ learn more about the various options available to you...// Omitted for brevity
9088

9189
This will wait until the model has generated its entire response before printing the results. Alternatively, if you want to asynchronously stream the response and print the results, you can replace the contents of *Program.cs* with the code in the next example.
9290

93-
### Async with streaming
94-
95-
```csharp
96-
using Azure;
97-
using Azure.AI.OpenAI;
98-
using Azure.AI.OpenAI.Chat;
99-
using OpenAI.Chat;
100-
using static System.Environment;
101-
102-
string azureOpenAIEndpoint = GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT");
103-
string azureOpenAIKey = GetEnvironmentVariable("AZURE_OPENAI_API_KEY");
104-
string deploymentName = GetEnvironmentVariable("AZURE_OPENAI_DEPLOYMENT_ID");
105-
string searchEndpoint = GetEnvironmentVariable("AZURE_AI_SEARCH_ENDPOINT");
106-
string searchKey = GetEnvironmentVariable("AZURE_AI_SEARCH_API_KEY");
107-
string searchIndex = GetEnvironmentVariable("AZURE_AI_SEARCH_INDEX");
108-
109-
#pragma warning disable AOAI001
110-
111-
AzureOpenAIClient azureClient = new(
112-
new Uri(azureOpenAIEndpoint),
113-
new AzureKeyCredential(azureOpenAIKey));
114-
ChatClient chatClient = azureClient.GetChatClient(deploymentName);
115-
116-
ChatCompletionOptions options = new();
117-
options.AddDataSource(new AzureSearchChatDataSource()
118-
{
119-
Endpoint = new Uri(searchEndpoint),
120-
IndexName = searchIndex,
121-
Authentication = DataSourceAuthentication.FromApiKey(searchKey),
122-
});
123-
124-
var chatUpdates = chatClient.CompleteChatStreamingAsync(
125-
[
126-
new UserChatMessage("What are my available health plans?"),
127-
], options);
128-
129-
AzureChatMessageContext onYourDataContext = null;
130-
await foreach (var chatUpdate in chatUpdates)
131-
{
132-
if (chatUpdate.Role.HasValue)
133-
{
134-
Console.WriteLine($"{chatUpdate.Role}: ");
135-
}
136-
137-
foreach (var contentPart in chatUpdate.ContentUpdate)
138-
{
139-
Console.Write(contentPart.Text);
140-
}
141-
142-
if (onYourDataContext == null)
143-
{
144-
onYourDataContext = chatUpdate.GetAzureMessageContext();
145-
}
146-
}
147-
148-
Console.WriteLine();
149-
if (onYourDataContext?.Intent is not null)
150-
{
151-
Console.WriteLine($"Intent: {onYourDataContext.Intent}");
152-
}
153-
foreach (AzureChatCitation citation in onYourDataContext?.Citations ?? [])
154-
{
155-
Console.Write($"Citation: {citation.Content}");
156-
}
157-
```
158-
159-

0 commit comments

Comments
 (0)