Add BasicChat-06OpenAIAPIs project for sentiment analysis#222
Merged
Conversation
Introduced a new project, `BasicChat-06OpenAIAPIs`, to the solution, targeting .NET 9.0 and integrating OpenAI's GPT model for sentiment analysis. Updated the solution file to support Visual Studio 18 and added build configurations for the new project. The project includes: - A `Program.cs` file demonstrating API key retrieval, prompt creation, and interaction with OpenAI's `ChatClient`. - Dependencies for AI and configuration management, including `Microsoft.Extensions.AI` and `OpenAI`. These changes enhance the solution with generative AI capabilities.
|
👋 Thanks for contributing @elbruno! We will review the pull request and get back to you soon. |
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds a new sentiment analysis project to the Core Generative AI Techniques solution, demonstrating the use of OpenAI's GPT model for analyzing product review sentiments. The addition provides a practical example of integrating OpenAI APIs into a .NET console application.
Key changes:
- Added a new console application project for sentiment analysis using OpenAI APIs
- Implemented configuration management for API keys using both environment variables and user secrets
- Created a sentiment analysis workflow that processes multiple product reviews and provides individual and overall sentiment assessments
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| CoreGenerativeAITechniques.sln | Added new BasicChat-06OpenAIAPIs project to solution with build configurations |
| Program.cs | Implemented main application logic for sentiment analysis using OpenAI GPT model |
| BasicChat-06OpenAIAPIs.csproj | Created project file with .NET 9.0 targeting and required NuGet packages |
Comments suppressed due to low confidence (2)
03-CoreGenerativeAITechniques/src/BasicChat-06OpenAIAPIs/Program.cs:13
- The model name 'gpt-4.1-mini' does not exist. OpenAI's available models include 'gpt-4o-mini' but not 'gpt-4.1-mini'. This will likely cause runtime errors when attempting to connect to the OpenAI API.
new OpenAI.Chat.ChatClient("gpt-4.1-mini", openai_apikey)
03-CoreGenerativeAITechniques/src/BasicChat-06OpenAIAPIs/Program.cs:5
- The variable name 'openai_apikey' uses snake_case which is inconsistent with C# naming conventions. It should be renamed to 'openAiApiKey' to follow camelCase convention.
var openai_apikey = Environment.GetEnvironmentVariable("APIKEY");
…am.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This pull request introduces a new project,
BasicChat-06OpenAIAPIs, to the solution and implements functionality for sentiment analysis using OpenAI's GPT model. Key changes include the addition of the project file, updates to the solution file, and implementation of the main program logic.Addition of the new project:
BasicChat-06OpenAIAPIs.csproj, targeting.NET 9.0and including dependencies for OpenAI and Microsoft Extensions libraries.CoreGenerativeAITechniques.sln, to include the new project and its build configurations for various platforms. [1] [2] [3] [4]Implementation of sentiment analysis:
Program.cs, which initializes an OpenAI chat client, builds a sentiment analysis prompt, sends it to the GPT model, and displays the response.