.NET: Inline const values in samples where used only once (#1387)

* Inline const values in samples where used only once

* Fix some spacing issues and use consistent ordering of settings/params
This commit is contained in:
westey
2025-10-10 16:50:53 +00:00
committed by GitHub
parent 3730db3e94
commit d6fdb91480
21 changed files with 53 additions and 106 deletions
@@ -10,14 +10,11 @@ using OpenAI;
var endpoint = Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT") ?? throw new InvalidOperationException("AZURE_OPENAI_ENDPOINT is not set.");
var deploymentName = Environment.GetEnvironmentVariable("AZURE_OPENAI_DEPLOYMENT_NAME") ?? "gpt-4o-mini";
const string JokerName = "Joker";
const string JokerInstructions = "You are good at telling jokes.";
AIAgent agent = new AzureOpenAIClient(
new Uri(endpoint),
new AzureCliCredential())
.GetChatClient(deploymentName)
.CreateAIAgent(JokerInstructions, JokerName);
.CreateAIAgent(instructions: "You are good at telling jokes.", name: "Joker");
// Invoke the agent and output the text result.
Console.WriteLine(await agent.RunAsync("Tell me a joke about a pirate."));