From 5f1417ab94f22756c1c957de77091a2f5557b260 Mon Sep 17 00:00:00 2001 From: SergeyMenshykh <68852919+SergeyMenshykh@users.noreply.github.com> Date: Wed, 1 Oct 2025 11:49:45 +0100 Subject: [PATCH] .NET: Align environment variable names (#1053) * alignt environment variable names * rename modelId variable names --- .../samples/A2AClientServer/A2AClient/README.md | 2 +- .../A2AServer/HostAgentFactory.cs | 6 +++--- .../samples/A2AClientServer/A2AServer/Program.cs | 16 ++++++++-------- dotnet/samples/A2AClientServer/README.md | 2 +- .../Agent_With_OpenAIAssistants/Program.cs | 6 +++--- .../Agent_With_OpenAIChatCompletion/Program.cs | 4 ++-- .../Agent_With_OpenAIResponses/Program.cs | 4 ++-- .../Workflows/Declarative/Program.cs | 2 +- .../Workflows/Declarative/README.md | 6 +++--- .../OpenAI/Step01_Basics/Program.cs | 6 +++--- .../OpenAI/Step02_ToolCall/Program.cs | 6 +++--- .../OpenAI/Step03_DependencyInjection/Program.cs | 6 +++--- .../OpenAIAssistants/Step01_Basics/Program.cs | 6 +++--- .../OpenAIAssistants/Step02_ToolCall/Program.cs | 6 +++--- .../Step03_DependencyInjection/Program.cs | 8 ++++---- .../Step04_CodeInterpreter/Program.cs | 6 +++--- .../OpenAIResponses/Step01_Basics/Program.cs | 6 +++--- .../Step02_ReasoningModel/Program.cs | 6 +++--- .../OpenAIResponses/Step03_ToolCall/Program.cs | 8 ++++---- .../Step04_DependencyInjection/Program.cs | 6 +++--- workflow-samples/README.md | 2 +- 21 files changed, 60 insertions(+), 60 deletions(-) diff --git a/dotnet/samples/A2AClientServer/A2AClient/README.md b/dotnet/samples/A2AClientServer/A2AClient/README.md index 324aa9aeee..c542430b22 100644 --- a/dotnet/samples/A2AClientServer/A2AClient/README.md +++ b/dotnet/samples/A2AClientServer/A2AClient/README.md @@ -20,7 +20,7 @@ The agent urls are provided as a ` ` delimited list of strings ```powershell cd dotnet/samples/A2AClientServer/A2AClient -$env:OPENAI_MODEL_ID="gpt-4o-mini" +$env:OPENAI_MODEL="gpt-4o-mini" $env:OPENAI_API_KEY="" $env:AGENT_URLS="http://localhost:5000/policy;http://localhost:5000/invoice;http://localhost:5000/logistics" ``` diff --git a/dotnet/samples/A2AClientServer/A2AServer/HostAgentFactory.cs b/dotnet/samples/A2AClientServer/A2AServer/HostAgentFactory.cs index f83abdb236..15e0f95831 100644 --- a/dotnet/samples/A2AClientServer/A2AServer/HostAgentFactory.cs +++ b/dotnet/samples/A2AClientServer/A2AServer/HostAgentFactory.cs @@ -12,7 +12,7 @@ namespace A2AServer; internal static class HostAgentFactory { - internal static async Task CreateFoundryHostAgentAsync(string agentType, string modelId, string endpoint, string assistantId, IList? tools = null) + internal static async Task CreateFoundryHostAgentAsync(string agentType, string model, string endpoint, string assistantId, IList? tools = null) { var persistentAgentsClient = new PersistentAgentsClient(endpoint, new AzureCliCredential()); PersistentAgent persistentAgent = await persistentAgentsClient.Administration.GetAgentAsync(assistantId); @@ -31,10 +31,10 @@ internal static class HostAgentFactory return new A2AHostAgent(agent, agentCard); } - internal static async Task CreateChatCompletionHostAgentAsync(string agentType, string modelId, string apiKey, string name, string instructions, IList? tools = null) + internal static async Task CreateChatCompletionHostAgentAsync(string agentType, string model, string apiKey, string name, string instructions, IList? tools = null) { AIAgent agent = new OpenAIClient(apiKey) - .GetChatClient(modelId) + .GetChatClient(model) .CreateAIAgent(instructions, name, tools: tools); AgentCard agentCard = agentType.ToUpperInvariant() switch diff --git a/dotnet/samples/A2AClientServer/A2AServer/Program.cs b/dotnet/samples/A2AClientServer/A2AServer/Program.cs index a6a24bc65e..1fd1b7077f 100644 --- a/dotnet/samples/A2AClientServer/A2AServer/Program.cs +++ b/dotnet/samples/A2AClientServer/A2AServer/Program.cs @@ -36,8 +36,8 @@ IConfigurationRoot configuration = new ConfigurationBuilder() .Build(); string? apiKey = configuration["OPENAI_API_KEY"]; -string modelId = configuration["OPENAI_MODEL_ID"] ?? "gpt-4o-mini"; -string? endpoint = configuration["FOUNDRY_PROJECT_ENDPOINT"]; +string model = configuration["OPENAI_MODEL"] ?? "gpt-4o-mini"; +string? endpoint = configuration["AZURE_FOUNDRY_PROJECT_ENDPOINT"]; var invoiceQueryPlugin = new InvoiceQuery(); IList tools = @@ -52,9 +52,9 @@ if (!string.IsNullOrEmpty(endpoint) && !string.IsNullOrEmpty(agentId)) { hostAgent = agentType.ToUpperInvariant() switch { - "INVOICE" => await HostAgentFactory.CreateFoundryHostAgentAsync(agentType, modelId, endpoint, agentId, tools), - "POLICY" => await HostAgentFactory.CreateFoundryHostAgentAsync(agentType, modelId, endpoint, agentId), - "LOGISTICS" => await HostAgentFactory.CreateFoundryHostAgentAsync(agentType, modelId, endpoint, agentId), + "INVOICE" => await HostAgentFactory.CreateFoundryHostAgentAsync(agentType, model, endpoint, agentId, tools), + "POLICY" => await HostAgentFactory.CreateFoundryHostAgentAsync(agentType, model, endpoint, agentId), + "LOGISTICS" => await HostAgentFactory.CreateFoundryHostAgentAsync(agentType, model, endpoint, agentId), _ => throw new ArgumentException($"Unsupported agent type: {agentType}"), }; } @@ -63,12 +63,12 @@ else if (!string.IsNullOrEmpty(apiKey)) hostAgent = agentType.ToUpperInvariant() switch { "INVOICE" => await HostAgentFactory.CreateChatCompletionHostAgentAsync( - agentType, modelId, apiKey, "InvoiceAgent", + agentType, model, apiKey, "InvoiceAgent", """ You specialize in handling queries related to invoices. """, tools), "POLICY" => await HostAgentFactory.CreateChatCompletionHostAgentAsync( - agentType, modelId, apiKey, "PolicyAgent", + agentType, model, apiKey, "PolicyAgent", """ You specialize in handling queries related to policies and customer communications. @@ -84,7 +84,7 @@ else if (!string.IsNullOrEmpty(apiKey)) template." """), "LOGISTICS" => await HostAgentFactory.CreateChatCompletionHostAgentAsync( - agentType, modelId, apiKey, "LogisticsAgent", + agentType, model, apiKey, "LogisticsAgent", """ You specialize in handling queries related to logistics. diff --git a/dotnet/samples/A2AClientServer/README.md b/dotnet/samples/A2AClientServer/README.md index 0311c0a2b7..76772a5e48 100644 --- a/dotnet/samples/A2AClientServer/README.md +++ b/dotnet/samples/A2AClientServer/README.md @@ -84,7 +84,7 @@ You must create the agents in an Azure AI Foundry project and then provide the p ``` ```powershell -$env:FOUNDRY_PROJECT_ENDPOINT="https://ai-foundry-your-project.services.ai.azure.com/api/projects/ai-proj-ga-your-project" # Replace with your Foundry Project endpoint +$env:AZURE_FOUNDRY_PROJECT_ENDPOINT="https://ai-foundry-your-project.services.ai.azure.com/api/projects/ai-proj-ga-your-project" # Replace with your Foundry Project endpoint ``` Use the following commands to run each A2A server diff --git a/dotnet/samples/GettingStarted/AgentProviders/Agent_With_OpenAIAssistants/Program.cs b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_OpenAIAssistants/Program.cs index 484430cad7..ce490b9892 100644 --- a/dotnet/samples/GettingStarted/AgentProviders/Agent_With_OpenAIAssistants/Program.cs +++ b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_OpenAIAssistants/Program.cs @@ -12,7 +12,7 @@ using Microsoft.Agents.AI; using OpenAI; var apiKey = Environment.GetEnvironmentVariable("OPENAI_APIKEY") ?? throw new InvalidOperationException("OPENAI_APIKEY is not set."); -var mmodel = Environment.GetEnvironmentVariable("OPENAI_MODEL") ?? "gpt-4o-mini"; +var model = Environment.GetEnvironmentVariable("OPENAI_MODEL") ?? "gpt-4o-mini"; const string JokerName = "Joker"; const string JokerInstructions = "You are good at telling jokes."; @@ -21,14 +21,14 @@ const string JokerInstructions = "You are good at telling jokes."; var assistantClient = new OpenAIClient(apiKey).GetAssistantClient(); // You can create a server side assistant with the OpenAI SDK. -var createResult = await assistantClient.CreateAssistantAsync(mmodel, new() { Name = JokerName, Instructions = JokerInstructions }); +var createResult = await assistantClient.CreateAssistantAsync(model, new() { Name = JokerName, Instructions = JokerInstructions }); // You can retrieve an already created server side assistant as an AIAgent. AIAgent agent1 = await assistantClient.GetAIAgentAsync(createResult.Value.Id); // You can also create a server side assistant and return it as an AIAgent directly. AIAgent agent2 = await assistantClient.CreateAIAgentAsync( - model: mmodel, + model: model, name: JokerName, instructions: JokerInstructions); diff --git a/dotnet/samples/GettingStarted/AgentProviders/Agent_With_OpenAIChatCompletion/Program.cs b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_OpenAIChatCompletion/Program.cs index 6d042762df..9b296859bb 100644 --- a/dotnet/samples/GettingStarted/AgentProviders/Agent_With_OpenAIChatCompletion/Program.cs +++ b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_OpenAIChatCompletion/Program.cs @@ -7,14 +7,14 @@ using Microsoft.Agents.AI; using OpenAI; var apiKey = Environment.GetEnvironmentVariable("OPENAI_APIKEY") ?? throw new InvalidOperationException("OPENAI_APIKEY is not set."); -var modelName = Environment.GetEnvironmentVariable("OPENAI_MODEL") ?? "gpt-4o-mini"; +var model = Environment.GetEnvironmentVariable("OPENAI_MODEL") ?? "gpt-4o-mini"; const string JokerName = "Joker"; const string JokerInstructions = "You are good at telling jokes."; AIAgent agent = new OpenAIClient( apiKey) - .GetChatClient(modelName) + .GetChatClient(model) .CreateAIAgent(JokerInstructions, JokerName); // Invoke the agent and output the text result. diff --git a/dotnet/samples/GettingStarted/AgentProviders/Agent_With_OpenAIResponses/Program.cs b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_OpenAIResponses/Program.cs index 6fb09040c6..8da7c29645 100644 --- a/dotnet/samples/GettingStarted/AgentProviders/Agent_With_OpenAIResponses/Program.cs +++ b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_OpenAIResponses/Program.cs @@ -9,14 +9,14 @@ using Microsoft.Agents.AI; using OpenAI; var apiKey = Environment.GetEnvironmentVariable("OPENAI_APIKEY") ?? throw new InvalidOperationException("OPENAI_APIKEY is not set."); -var modelName = Environment.GetEnvironmentVariable("OPENAI_MODEL") ?? "gpt-4o-mini"; +var model = Environment.GetEnvironmentVariable("OPENAI_MODEL") ?? "gpt-4o-mini"; const string JokerName = "Joker"; const string JokerInstructions = "You are good at telling jokes."; AIAgent agent = new OpenAIClient( apiKey) - .GetOpenAIResponseClient(modelName) + .GetOpenAIResponseClient(model) .CreateAIAgent(JokerInstructions, JokerName); // Invoke the agent and output the text result. diff --git a/dotnet/samples/GettingStarted/Workflows/Declarative/Program.cs b/dotnet/samples/GettingStarted/Workflows/Declarative/Program.cs index 073650274c..132ea9a5cb 100644 --- a/dotnet/samples/GettingStarted/Workflows/Declarative/Program.cs +++ b/dotnet/samples/GettingStarted/Workflows/Declarative/Program.cs @@ -22,7 +22,7 @@ namespace Demo.DeclarativeWorkflow; /// /// /// Configuration -/// Define FOUNDRY_PROJECT_ENDPOINT as a user-secret or environment variable that +/// Define AZURE_FOUNDRY_PROJECT_ENDPOINT as a user-secret or environment variable that /// points to your Foundry project endpoint. /// Usage /// Provide the path to the workflow definition file as the first argument. diff --git a/dotnet/samples/GettingStarted/Workflows/Declarative/README.md b/dotnet/samples/GettingStarted/Workflows/Declarative/README.md index 9b8702fa6a..f224c014b7 100644 --- a/dotnet/samples/GettingStarted/Workflows/Declarative/README.md +++ b/dotnet/samples/GettingStarted/Workflows/Declarative/README.md @@ -16,7 +16,7 @@ You can also use environment variables if you prefer. To set your secrets as an environment variable (PowerShell): ```pwsh -$env:FOUNDRY_PROJECT_ENDPOINT="https://..." +$env:AZURE_FOUNDRY_PROJECT_ENDPOINT="https://..." ``` To set your secrets with .NET Secret Manager: @@ -42,7 +42,7 @@ To set your secrets with .NET Secret Manager: 4. Define setting that identifies your Azure Foundry Project (endpoint): ``` - dotnet user-secrets set "FOUNDRY_PROJECT_ENDPOINT" "https://..." + dotnet user-secrets set "AZURE_FOUNDRY_PROJECT_ENDPOINT" "https://..." ``` #### Authorization @@ -61,7 +61,7 @@ The sample workflows rely on agents defined in your Azure Foundry Project. To create agents, run the [`Create.ps1`](../../../../../workflows/) script. This will create the agents used in the sample workflows in your Azure Foundry Project and format a script you can copy and use to configure your environment. -> Note: `Create.ps1` relies upon the `FOUNDRY_PROJECT_ENDPOINT` setting. +> Note: `Create.ps1` relies upon the `AZURE_FOUNDRY_PROJECT_ENDPOINT` setting. ## Execution diff --git a/dotnet/samples/SemanticKernelMigration/OpenAI/Step01_Basics/Program.cs b/dotnet/samples/SemanticKernelMigration/OpenAI/Step01_Basics/Program.cs index f1f7506c6f..05242defce 100644 --- a/dotnet/samples/SemanticKernelMigration/OpenAI/Step01_Basics/Program.cs +++ b/dotnet/samples/SemanticKernelMigration/OpenAI/Step01_Basics/Program.cs @@ -7,7 +7,7 @@ using Microsoft.SemanticKernel.Connectors.OpenAI; using OpenAI; var apiKey = Environment.GetEnvironmentVariable("OPENAI_API_KEY") ?? throw new InvalidOperationException("OPENAI_API_KEY is not set."); -var modelId = System.Environment.GetEnvironmentVariable("OPENAI_MODELID") ?? "gpt-4o"; +var model = System.Environment.GetEnvironmentVariable("OPENAI_MODEL") ?? "gpt-4o"; var userInput = "Tell me a joke about a pirate."; Console.WriteLine($"User Input: {userInput}"); @@ -19,7 +19,7 @@ async Task SKAgentAsync() { Console.WriteLine("\n=== SK Agent ===\n"); - var builder = Kernel.CreateBuilder().AddOpenAIChatClient(modelId, apiKey); + var builder = Kernel.CreateBuilder().AddOpenAIChatClient(model, apiKey); var agent = new ChatCompletionAgent() { @@ -48,7 +48,7 @@ async Task AFAgentAsync() { Console.WriteLine("\n=== AF Agent ===\n"); - var agent = new OpenAIClient(apiKey).GetChatClient(modelId) + var agent = new OpenAIClient(apiKey).GetChatClient(model) .CreateAIAgent(name: "Joker", instructions: "You are good at telling jokes."); var thread = agent.GetNewThread(); diff --git a/dotnet/samples/SemanticKernelMigration/OpenAI/Step02_ToolCall/Program.cs b/dotnet/samples/SemanticKernelMigration/OpenAI/Step02_ToolCall/Program.cs index e70a546585..c353518659 100644 --- a/dotnet/samples/SemanticKernelMigration/OpenAI/Step02_ToolCall/Program.cs +++ b/dotnet/samples/SemanticKernelMigration/OpenAI/Step02_ToolCall/Program.cs @@ -7,7 +7,7 @@ using Microsoft.SemanticKernel.Agents; using OpenAI; var apiKey = Environment.GetEnvironmentVariable("OPENAI_API_KEY") ?? throw new InvalidOperationException("OPENAI_API_KEY is not set."); -var modelId = System.Environment.GetEnvironmentVariable("OPENAI_MODELID") ?? "gpt-4o"; +var model = System.Environment.GetEnvironmentVariable("OPENAI_MODEL") ?? "gpt-4o"; var userInput = "What is the weather like in Amsterdam?"; Console.WriteLine($"User Input: {userInput}"); @@ -22,7 +22,7 @@ await AFAgentAsync(); async Task SKAgentAsync() { - var builder = Kernel.CreateBuilder().AddOpenAIChatClient(modelId, apiKey); + var builder = Kernel.CreateBuilder().AddOpenAIChatClient(model, apiKey); ChatCompletionAgent agent = new() { @@ -42,7 +42,7 @@ async Task SKAgentAsync() async Task AFAgentAsync() { - var agent = new OpenAIClient(apiKey).GetChatClient(modelId).CreateAIAgent( + var agent = new OpenAIClient(apiKey).GetChatClient(model).CreateAIAgent( instructions: "You are a helpful assistant", tools: [AIFunctionFactory.Create(GetWeather)]); diff --git a/dotnet/samples/SemanticKernelMigration/OpenAI/Step03_DependencyInjection/Program.cs b/dotnet/samples/SemanticKernelMigration/OpenAI/Step03_DependencyInjection/Program.cs index 139a373633..0ffdc75902 100644 --- a/dotnet/samples/SemanticKernelMigration/OpenAI/Step03_DependencyInjection/Program.cs +++ b/dotnet/samples/SemanticKernelMigration/OpenAI/Step03_DependencyInjection/Program.cs @@ -8,7 +8,7 @@ using Microsoft.SemanticKernel.Agents; using OpenAI; var apiKey = Environment.GetEnvironmentVariable("OPENAI_API_KEY") ?? throw new InvalidOperationException("OPENAI_API_KEY is not set."); -var modelId = System.Environment.GetEnvironmentVariable("OPENAI_MODELID") ?? "gpt-4o"; +var model = System.Environment.GetEnvironmentVariable("OPENAI_MODEL") ?? "gpt-4o"; var userInput = "Tell me a joke about a pirate."; Console.WriteLine($"User Input: {userInput}"); @@ -21,7 +21,7 @@ async Task SKAgentAsync() Console.WriteLine("\n=== SK Agent ===\n"); var serviceCollection = new ServiceCollection(); - serviceCollection.AddKernel().AddOpenAIChatClient(modelId, apiKey); + serviceCollection.AddKernel().AddOpenAIChatClient(model, apiKey); serviceCollection.AddTransient((sp) => new ChatCompletionAgent() { Kernel = sp.GetRequiredService(), @@ -42,7 +42,7 @@ async Task AFAgentAsync() var serviceCollection = new ServiceCollection(); serviceCollection.AddTransient((sp) => new OpenAIClient(apiKey) - .GetChatClient(modelId) + .GetChatClient(model) .CreateAIAgent(name: "Joker", instructions: "You are good at telling jokes.")); await using ServiceProvider serviceProvider = serviceCollection.BuildServiceProvider(); diff --git a/dotnet/samples/SemanticKernelMigration/OpenAIAssistants/Step01_Basics/Program.cs b/dotnet/samples/SemanticKernelMigration/OpenAIAssistants/Step01_Basics/Program.cs index 1f0593e34d..4ff054ba2f 100644 --- a/dotnet/samples/SemanticKernelMigration/OpenAIAssistants/Step01_Basics/Program.cs +++ b/dotnet/samples/SemanticKernelMigration/OpenAIAssistants/Step01_Basics/Program.cs @@ -9,7 +9,7 @@ using OpenAI; using OpenAI.Assistants; var apiKey = Environment.GetEnvironmentVariable("OPENAI_API_KEY") ?? throw new InvalidOperationException("OPENAI_API_KEY is not set."); -var modelId = System.Environment.GetEnvironmentVariable("OPENAI_MODELID") ?? "gpt-4o"; +var model = System.Environment.GetEnvironmentVariable("OPENAI_MODEL") ?? "gpt-4o"; var userInput = "Tell me a joke about a pirate."; Console.WriteLine($"User Input: {userInput}"); @@ -24,7 +24,7 @@ async Task SKAgentAsync() var assistantsClient = new AssistantClient(apiKey); // Define the assistant - Assistant assistant = await assistantsClient.CreateAssistantAsync(modelId, name: "Joker", instructions: "You are good at telling jokes."); + Assistant assistant = await assistantsClient.CreateAssistantAsync(model, name: "Joker", instructions: "You are good at telling jokes."); // Create the agent OpenAIAssistantAgent agent = new(assistant, assistantsClient); @@ -56,7 +56,7 @@ async Task AFAgentAsync() var assistantClient = new AssistantClient(apiKey); - var agent = await assistantClient.CreateAIAgentAsync(modelId, name: "Joker", instructions: "You are good at telling jokes."); + var agent = await assistantClient.CreateAIAgentAsync(model, name: "Joker", instructions: "You are good at telling jokes."); var thread = agent.GetNewThread(); var agentOptions = new ChatClientAgentRunOptions(new() { MaxOutputTokens = 1000 }); diff --git a/dotnet/samples/SemanticKernelMigration/OpenAIAssistants/Step02_ToolCall/Program.cs b/dotnet/samples/SemanticKernelMigration/OpenAIAssistants/Step02_ToolCall/Program.cs index cf33a2f8b9..7046a28265 100644 --- a/dotnet/samples/SemanticKernelMigration/OpenAIAssistants/Step02_ToolCall/Program.cs +++ b/dotnet/samples/SemanticKernelMigration/OpenAIAssistants/Step02_ToolCall/Program.cs @@ -12,7 +12,7 @@ using OpenAI; using OpenAI.Assistants; var apiKey = Environment.GetEnvironmentVariable("OPENAI_API_KEY") ?? throw new InvalidOperationException("OPENAI_API_KEY is not set."); -var modelId = System.Environment.GetEnvironmentVariable("OPENAI_MODELID") ?? "gpt-4o"; +var model = System.Environment.GetEnvironmentVariable("OPENAI_MODEL") ?? "gpt-4o"; var userInput = "What is the weather like in Amsterdam?"; [KernelFunction] @@ -32,7 +32,7 @@ async Task SKAgentAsync() var builder = Kernel.CreateBuilder(); var assistantsClient = new AssistantClient(apiKey); - Assistant assistant = await assistantsClient.CreateAssistantAsync(modelId, + Assistant assistant = await assistantsClient.CreateAssistantAsync(model, instructions: "You are a helpful assistant"); OpenAIAssistantAgent agent = new(assistant, assistantsClient) @@ -73,7 +73,7 @@ async Task AFAgentAsync() var assistantClient = new AssistantClient(apiKey); - var agent = await assistantClient.CreateAIAgentAsync(modelId, + var agent = await assistantClient.CreateAIAgentAsync(model, instructions: "You are a helpful assistant", tools: [AIFunctionFactory.Create(GetWeather)]); diff --git a/dotnet/samples/SemanticKernelMigration/OpenAIAssistants/Step03_DependencyInjection/Program.cs b/dotnet/samples/SemanticKernelMigration/OpenAIAssistants/Step03_DependencyInjection/Program.cs index 76bf0ffbfc..1ddac9ec1c 100644 --- a/dotnet/samples/SemanticKernelMigration/OpenAIAssistants/Step03_DependencyInjection/Program.cs +++ b/dotnet/samples/SemanticKernelMigration/OpenAIAssistants/Step03_DependencyInjection/Program.cs @@ -11,7 +11,7 @@ using OpenAI; using OpenAI.Assistants; var apiKey = Environment.GetEnvironmentVariable("OPENAI_API_KEY") ?? throw new InvalidOperationException("OPENAI_API_KEY is not set."); -var modelId = System.Environment.GetEnvironmentVariable("OPENAI_MODELID") ?? "gpt-4o"; +var model = System.Environment.GetEnvironmentVariable("OPENAI_MODEL") ?? "gpt-4o"; var userInput = "Tell me a joke about a pirate."; Console.WriteLine($"User Input: {userInput}"); @@ -25,12 +25,12 @@ async Task SKAgentAsync() var serviceCollection = new ServiceCollection(); serviceCollection.AddSingleton((sp) => new AssistantClient(apiKey)); - serviceCollection.AddKernel().AddOpenAIChatClient(modelId, apiKey); + serviceCollection.AddKernel().AddOpenAIChatClient(model, apiKey); serviceCollection.AddTransient((sp) => { var assistantsClient = sp.GetRequiredService(); - Assistant assistant = assistantsClient.CreateAssistant(modelId, new() { Name = "Joker", Instructions = "You are good at telling jokes." }); + Assistant assistant = assistantsClient.CreateAssistant(model, new() { Name = "Joker", Instructions = "You are good at telling jokes." }); return new OpenAIAssistantAgent(assistant, assistantsClient); }); @@ -70,7 +70,7 @@ async Task AFAgentAsync() { var assistantClient = sp.GetRequiredService(); - return assistantClient.CreateAIAgent(modelId, name: "Joker", instructions: "You are good at telling jokes."); + return assistantClient.CreateAIAgent(model, name: "Joker", instructions: "You are good at telling jokes."); }); await using ServiceProvider serviceProvider = serviceCollection.BuildServiceProvider(); diff --git a/dotnet/samples/SemanticKernelMigration/OpenAIAssistants/Step04_CodeInterpreter/Program.cs b/dotnet/samples/SemanticKernelMigration/OpenAIAssistants/Step04_CodeInterpreter/Program.cs index 9e0ec0dbf4..8ac1bb5a07 100644 --- a/dotnet/samples/SemanticKernelMigration/OpenAIAssistants/Step04_CodeInterpreter/Program.cs +++ b/dotnet/samples/SemanticKernelMigration/OpenAIAssistants/Step04_CodeInterpreter/Program.cs @@ -13,7 +13,7 @@ using OpenAI.Assistants; #pragma warning disable CS8321 // Local function is declared but never used var apiKey = Environment.GetEnvironmentVariable("OPENAI_API_KEY") ?? throw new InvalidOperationException("OPENAI_API_KEY is not set."); -var modelId = System.Environment.GetEnvironmentVariable("OPENAI_MODELID") ?? "gpt-4o"; +var model = System.Environment.GetEnvironmentVariable("OPENAI_MODEL") ?? "gpt-4o"; var userInput = "Create a python code file using the code interpreter tool with a code ready to determine the values in the Fibonacci sequence that are less then the value of 101"; var assistantsClient = new AssistantClient(apiKey); @@ -28,7 +28,7 @@ async Task SKAgentAsync() Console.WriteLine("\n=== SK Agent ===\n"); // Define the assistant - Assistant assistant = await assistantsClient.CreateAssistantAsync(modelId, enableCodeInterpreter: true); + Assistant assistant = await assistantsClient.CreateAssistantAsync(model, enableCodeInterpreter: true); // Create the agent OpenAIAssistantAgent agent = new(assistant, assistantsClient); @@ -74,7 +74,7 @@ async Task AFAgentAsync() { Console.WriteLine("\n=== AF Agent ===\n"); - var agent = await assistantsClient.CreateAIAgentAsync(modelId, tools: [new HostedCodeInterpreterTool()]); + var agent = await assistantsClient.CreateAIAgentAsync(model, tools: [new HostedCodeInterpreterTool()]); var thread = agent.GetNewThread(); diff --git a/dotnet/samples/SemanticKernelMigration/OpenAIResponses/Step01_Basics/Program.cs b/dotnet/samples/SemanticKernelMigration/OpenAIResponses/Step01_Basics/Program.cs index b8edd253b0..5c6a501e10 100644 --- a/dotnet/samples/SemanticKernelMigration/OpenAIResponses/Step01_Basics/Program.cs +++ b/dotnet/samples/SemanticKernelMigration/OpenAIResponses/Step01_Basics/Program.cs @@ -8,7 +8,7 @@ using OpenAI; #pragma warning disable OPENAI001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed. var apiKey = Environment.GetEnvironmentVariable("OPENAI_API_KEY") ?? throw new InvalidOperationException("OPENAI_API_KEY is not set."); -var modelId = System.Environment.GetEnvironmentVariable("OPENAI_MODELID") ?? "gpt-4o"; +var model = System.Environment.GetEnvironmentVariable("OPENAI_MODEL") ?? "gpt-4o"; var userInput = "Tell me a joke about a pirate."; Console.WriteLine($"User Input: {userInput}"); @@ -20,7 +20,7 @@ async Task SKAgentAsync() { Console.WriteLine("\n=== SK Agent ===\n"); - var responseClient = new OpenAIClient(apiKey).GetOpenAIResponseClient(modelId); + var responseClient = new OpenAIClient(apiKey).GetOpenAIResponseClient(model); OpenAIResponseAgent agent = new(responseClient) { Name = "Joker", @@ -50,7 +50,7 @@ async Task AFAgentAsync() { Console.WriteLine("\n=== AF Agent ===\n"); - var agent = new OpenAIClient(apiKey).GetOpenAIResponseClient(modelId) + var agent = new OpenAIClient(apiKey).GetOpenAIResponseClient(model) .CreateAIAgent(name: "Joker", instructions: "You are good at telling jokes."); var thread = agent.GetNewThread(); diff --git a/dotnet/samples/SemanticKernelMigration/OpenAIResponses/Step02_ReasoningModel/Program.cs b/dotnet/samples/SemanticKernelMigration/OpenAIResponses/Step02_ReasoningModel/Program.cs index b0ac702ad2..befe386495 100644 --- a/dotnet/samples/SemanticKernelMigration/OpenAIResponses/Step02_ReasoningModel/Program.cs +++ b/dotnet/samples/SemanticKernelMigration/OpenAIResponses/Step02_ReasoningModel/Program.cs @@ -11,7 +11,7 @@ using OpenAI; #pragma warning disable OPENAI001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed. var apiKey = Environment.GetEnvironmentVariable("OPENAI_API_KEY") ?? throw new InvalidOperationException("OPENAI_API_KEY is not set."); -var modelId = System.Environment.GetEnvironmentVariable("OPENAI_MODELID") ?? "o4-mini"; +var model = System.Environment.GetEnvironmentVariable("OPENAI_MODEL") ?? "o4-mini"; var userInput = """ Instructions: @@ -47,7 +47,7 @@ async Task SKAgentAsync() { Console.WriteLine("\n=== SK Agent ===\n"); - var responseClient = new OpenAIClient(apiKey).GetOpenAIResponseClient(modelId); + var responseClient = new OpenAIClient(apiKey).GetOpenAIResponseClient(model); OpenAIResponseAgent agent = new(responseClient) { Name = "Thinker", @@ -115,7 +115,7 @@ async Task AFAgentAsync() { Console.WriteLine("\n=== AF Agent ===\n"); - var agent = new OpenAIClient(apiKey).GetOpenAIResponseClient(modelId) + var agent = new OpenAIClient(apiKey).GetOpenAIResponseClient(model) .CreateAIAgent(name: "Thinker", instructions: "You are at thinking hard before answering."); var thread = agent.GetNewThread(); diff --git a/dotnet/samples/SemanticKernelMigration/OpenAIResponses/Step03_ToolCall/Program.cs b/dotnet/samples/SemanticKernelMigration/OpenAIResponses/Step03_ToolCall/Program.cs index 81634b2ed2..c0dbc1c5cf 100644 --- a/dotnet/samples/SemanticKernelMigration/OpenAIResponses/Step03_ToolCall/Program.cs +++ b/dotnet/samples/SemanticKernelMigration/OpenAIResponses/Step03_ToolCall/Program.cs @@ -9,7 +9,7 @@ using OpenAI; #pragma warning disable OPENAI001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed. var apiKey = Environment.GetEnvironmentVariable("OPENAI_API_KEY") ?? throw new InvalidOperationException("OPENAI_API_KEY is not set."); -var modelId = System.Environment.GetEnvironmentVariable("OPENAI_MODELID") ?? "gpt-4o"; +var model = System.Environment.GetEnvironmentVariable("OPENAI_MODEL") ?? "gpt-4o"; var userInput = "What is the weather like in Amsterdam?"; Console.WriteLine($"User Input: {userInput}"); @@ -24,9 +24,9 @@ await AFAgentAsync(); async Task SKAgentAsync() { - var builder = Kernel.CreateBuilder().AddOpenAIChatClient(modelId, apiKey); + var builder = Kernel.CreateBuilder().AddOpenAIChatClient(model, apiKey); - OpenAIResponseAgent agent = new(new OpenAIClient(apiKey).GetOpenAIResponseClient(modelId)); + OpenAIResponseAgent agent = new(new OpenAIClient(apiKey).GetOpenAIResponseClient(model)); // Initialize plugin and add to the agent's Kernel (same as direct Kernel usage). agent.Kernel.Plugins.Add(KernelPluginFactory.CreateFromFunctions("KernelPluginName", [KernelFunctionFactory.CreateFromMethod(GetWeather)])); @@ -44,7 +44,7 @@ async Task SKAgentAsync() async Task AFAgentAsync() { - var agent = new OpenAIClient(apiKey).GetOpenAIResponseClient(modelId).CreateAIAgent( + var agent = new OpenAIClient(apiKey).GetOpenAIResponseClient(model).CreateAIAgent( instructions: "You are a helpful assistant", tools: [AIFunctionFactory.Create(GetWeather)]); diff --git a/dotnet/samples/SemanticKernelMigration/OpenAIResponses/Step04_DependencyInjection/Program.cs b/dotnet/samples/SemanticKernelMigration/OpenAIResponses/Step04_DependencyInjection/Program.cs index d3eea54107..6859f2c385 100644 --- a/dotnet/samples/SemanticKernelMigration/OpenAIResponses/Step04_DependencyInjection/Program.cs +++ b/dotnet/samples/SemanticKernelMigration/OpenAIResponses/Step04_DependencyInjection/Program.cs @@ -9,7 +9,7 @@ using OpenAI; #pragma warning disable OPENAI001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed. var apiKey = Environment.GetEnvironmentVariable("OPENAI_API_KEY") ?? throw new InvalidOperationException("OPENAI_API_KEY is not set."); -var modelId = System.Environment.GetEnvironmentVariable("OPENAI_MODELID") ?? "gpt-4o"; +var model = System.Environment.GetEnvironmentVariable("OPENAI_MODEL") ?? "gpt-4o"; var userInput = "Tell me a joke about a pirate."; Console.WriteLine($"User Input: {userInput}"); @@ -23,7 +23,7 @@ async Task SKAgentAsync() var serviceCollection = new ServiceCollection(); serviceCollection.AddTransient((sp) - => new OpenAIResponseAgent(new OpenAIClient(apiKey).GetOpenAIResponseClient(modelId)) + => new OpenAIResponseAgent(new OpenAIClient(apiKey).GetOpenAIResponseClient(model)) { Name = "Joker", Instructions = "You are good at telling jokes." @@ -42,7 +42,7 @@ async Task AFAgentAsync() var serviceCollection = new ServiceCollection(); serviceCollection.AddTransient((sp) => new OpenAIClient(apiKey) - .GetOpenAIResponseClient(modelId) + .GetOpenAIResponseClient(model) .CreateAIAgent(name: "Joker", instructions: "You are good at telling jokes.")); await using ServiceProvider serviceProvider = serviceCollection.BuildServiceProvider(); diff --git a/workflow-samples/README.md b/workflow-samples/README.md index 56911c1783..b40d3d51a3 100644 --- a/workflow-samples/README.md +++ b/workflow-samples/README.md @@ -24,4 +24,4 @@ The sample workflows rely on agents defined in your Azure Foundry Project. To create agents, run the [`Create.ps1`](./setup) script. This will create the agents used in the sample workflows in your Azure Foundry Project and format a script you can copy and use to configure your environment. -> Note: `Create.ps1` relies upon the `FOUNDRY_PROJECT_ENDPOINT` setting. See [README.md](../dotnet/demos/DeclarativeWorkflow/README.md) from the demo for configuration details. +> Note: `Create.ps1` relies upon the `AZURE_FOUNDRY_PROJECT_ENDPOINT` setting. See [README.md](../dotnet/demos/DeclarativeWorkflow/README.md) from the demo for configuration details.