Skip to content

Commit e7b261c

Browse files
Merge pull request #107823 from IEvangelist/patch-5
Update dotnet.md
2 parents 1034d98 + 90e92a2 commit e7b261c

File tree

1 file changed

+11
-19
lines changed
  • articles/cognitive-services/openai/includes

1 file changed

+11
-19
lines changed

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

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -112,29 +112,21 @@ using Azure;
112112
using Azure.AI.OpenAI;
113113
using static System.Environment;
114114

115-
namespace azure_openai_quickstart
116-
{
117-
internal class Program
118-
{
119-
static void Main(string[] args)
120-
{
121-
string endpoint = GetEnvironmentVariable("OPENAI_API_BASE");
122-
string key = GetEnvironmentVariable("OPENAI_API_KEY");
123-
string engine = "text-davinci-003"; //Enter the deployment name you chose when you deployed the model.
115+
string endpoint = GetEnvironmentVariable("OPENAI_API_BASE");
116+
string key = GetEnvironmentVariable("OPENAI_API_KEY");
124117

125-
OpenAIClient client = new OpenAIClient(new Uri(endpoint), new AzureKeyCredential(key));
118+
// Enter the deployment name you chose when you deployed the model.
119+
string engine = "text-davinci-003";
126120

127-
string prompt = "When was Microsoft founded?";
128-
Console.Write($"Input: {prompt}\n");
121+
OpenAIClient client = new(new Uri(endpoint), new AzureKeyCredential(key));
129122

130-
Response<Completions> completionsResponse = client.GetCompletions(engine, prompt);
131-
string completion = completionsResponse.Value.Choices[0].Text;
132-
Console.WriteLine($"Chatbot: {completion}");
133-
134-
}
135-
}
136-
}
123+
string prompt = "When was Microsoft founded?";
124+
Console.Write($"Input: {prompt}\n");
137125

126+
Response<Completions> completionsResponse =
127+
await client.GetCompletionsAsync(engine, prompt);
128+
string completion = completionsResponse.Value.Choices[0].Text;
129+
Console.WriteLine($"Chatbot: {completion}");
138130
```
139131

140132
> [!IMPORTANT]

0 commit comments

Comments
 (0)