-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add new projects to showcase the use of o3-mini model with SK #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
03-CoreGenerativeAITechniques/src/ReasoningLabs-01-SK/Program.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 = []; | ||
| 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); | ||
|
|
||
17 changes: 17 additions & 0 deletions
17
03-CoreGenerativeAITechniques/src/ReasoningLabs-01-SK/ReasoningLabs-01-SK.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.