Skip to content

Add BasicChat-06OpenAIAPIs project for sentiment analysis#222

Merged
elbruno merged 2 commits into
mainfrom
bruno-add-basichat-openai-sample
Jul 31, 2025
Merged

Add BasicChat-06OpenAIAPIs project for sentiment analysis#222
elbruno merged 2 commits into
mainfrom
bruno-add-basichat-openai-sample

Conversation

@elbruno
Copy link
Copy Markdown
Collaborator

@elbruno elbruno commented Jul 31, 2025

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:

  • Created a new project file, BasicChat-06OpenAIAPIs.csproj, targeting .NET 9.0 and including dependencies for OpenAI and Microsoft Extensions libraries.
  • Updated the solution file, CoreGenerativeAITechniques.sln, to include the new project and its build configurations for various platforms. [1] [2] [3] [4]

Implementation of sentiment analysis:

  • Added the main program logic in Program.cs, which initializes an OpenAI chat client, builds a sentiment analysis prompt, sends it to the GPT model, and displays the response.

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.
@github-actions
Copy link
Copy Markdown

👋 Thanks for contributing @elbruno! We will review the pull request and get back to you soon.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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");

Comment thread 03-CoreGenerativeAITechniques/src/BasicChat-06OpenAIAPIs/Program.cs Outdated
…am.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@elbruno elbruno merged commit 277410f into main Jul 31, 2025
5 checks passed
@elbruno elbruno deleted the bruno-add-basichat-openai-sample branch July 31, 2025 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants