Skip to content

Commit 6416b65

Browse files
authored
Update dotnet.md
Modernize and help simplify the C# bits.
1 parent 62e702a commit 6416b65

File tree

1 file changed

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

1 file changed

+10
-19
lines changed

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

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -112,29 +112,20 @@ 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 = client.GetCompletions(engine, prompt);
127+
string completion = completionsResponse.Value.Choices[0].Text;
128+
Console.WriteLine($"Chatbot: {completion}");
138129
```
139130

140131
> [!IMPORTANT]

0 commit comments

Comments
 (0)