Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MEAIFunctions", "MEAIFuncti
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MEAIFunctionsOllama", "MEAIFunctionsOllama\MEAIFunctionsOllama.csproj", "{B0A1DF75-4625-45D5-87B0-29F7290F63E1}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "07 Reasoning", "07 Reasoning", "{301F771F-CBE6-4D34-A24A-02F7DE5463DC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReasoningLabs-01-SK", "ReasoningLabs-01-SK\ReasoningLabs-01-SK.csproj", "{7274D8C3-EC9B-4D54-B472-CBE1E44C39AC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -135,6 +139,10 @@ Global
{B0A1DF75-4625-45D5-87B0-29F7290F63E1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B0A1DF75-4625-45D5-87B0-29F7290F63E1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B0A1DF75-4625-45D5-87B0-29F7290F63E1}.Release|Any CPU.Build.0 = Release|Any CPU
{7274D8C3-EC9B-4D54-B472-CBE1E44C39AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7274D8C3-EC9B-4D54-B472-CBE1E44C39AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7274D8C3-EC9B-4D54-B472-CBE1E44C39AC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7274D8C3-EC9B-4D54-B472-CBE1E44C39AC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -159,6 +167,7 @@ Global
{35DF7A10-DE5D-41CA-9940-F93FA1385534} = {B5980212-D3CF-4A46-94EA-3B22EFAD1257}
{33CE094D-6C79-4151-87D5-8D49A9982328} = {F5798C6F-98D6-4411-A5F0-F928CBA64095}
{B0A1DF75-4625-45D5-87B0-29F7290F63E1} = {F5798C6F-98D6-4411-A5F0-F928CBA64095}
{7274D8C3-EC9B-4D54-B472-CBE1E44C39AC} = {301F771F-CBE6-4D34-A24A-02F7DE5463DC}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {961EEBAB-4149-4AA4-BEE7-9DAAE4C94133}
Expand Down
51 changes: 51 additions & 0 deletions 03-CoreGenerativeAITechniques/src/ReasoningLabs-01-SK/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#pragma warning disable SKEXP0010 // Reasoning effort is still in preview for OpenAI SDK.

using Microsoft.Extensions.Configuration;
using Microsoft.SemanticKernel.ChatCompletion;
using Microsoft.SemanticKernel.Connectors.AzureOpenAI;
using Microsoft.SemanticKernel.Connectors.OpenAI;

// ==============================
// Using Azure OpenAI models
// ==============================
//var deploymentName = Environment.GetEnvironmentVariable("AZURE_OPENAI_DEPLOYMENT");
//var endpoint = Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT");
//var apiKey = Environment.GetEnvironmentVariable("AZURE_OPENAI_APIKEY");
//var modelId = Environment.GetEnvironmentVariable("AZURE_OPENAI_MODEL");
//if (string.IsNullOrEmpty(endpoint))
//{
// var config = new ConfigurationBuilder().AddUserSecrets<Program>().Build();
// deploymentName = config["AZURE_OPENAI_DEPLOYMENT"];
// endpoint = config["AZURE_OPENAI_ENDPOINT"];
// apiKey = config["AZURE_OPENAI_APIKEY"];
// modelId = config["AZURE_OPENAI_MODEL"];
//}

//// Initialize the OpenAI chat completion service with the o3-mini model.
//var chatService = new AzureOpenAIChatCompletionService(
// deploymentName: deploymentName,
// endpoint: endpoint,
// apiKey: apiKey,
// modelId: modelId
//);

// ==============================
// Using OpenAI API directly
// ==============================
// Initialize the OpenAI chat completion service with the o3-mini model.
var chatService = new OpenAIChatCompletionService(
modelId: "o3-mini", // OpenAI API endpoint
apiKey: "" // Your OpenAI API key
);

// Create a new chat history and add a user message to prompt the model.
ChatHistory chatHistory = [];
Copy link

Copilot AI Feb 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ChatHistory should be initialized as a list or a collection, not an empty array. Use new List<ChatMessage>() instead.

Suggested change
ChatHistory chatHistory = [];
ChatHistory chatHistory = new List<ChatMessage>();

Copilot uses AI. Check for mistakes.
chatHistory.AddUserMessage("Why is the sky blue in one sentence?");

// Configure reasoning effort for the chat completion request.
var settings = new OpenAIPromptExecutionSettings { ReasoningEffort = "high" };

// Send the chat completion request to o3-mini
var reply = await chatService.GetChatMessageContentAsync(chatHistory, settings);
Console.WriteLine("o3-mini reply: " + reply);

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<RootNamespace>ReasoningLabs_01_SK</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UserSecretsId>585e845e-c369-447f-9e0b-de6c8b4e3a86</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="6.0.1" />
<PackageReference Include="Microsoft.SemanticKernel" Version="1.37.0" />
</ItemGroup>

</Project>