Welcome to the GPT-4o Labs samples using C#. This repository contains a demo projects that showcases how to integrate the powerful GPT-4o model with the new OpenAI Library for .NET and Semantic Kernel in a .NET environment.
Before running the sample, ensure you have the following installed:
- .NET 8: Make sure you have the latest version of .NET installed on your machine.
- (Optional) OpenAI Key: An OpenAI API key is required to authenticate and interact with the GPT-4o model.
- (Optional) Azure OpenAI Services: A GPT-4o model deployed in Azure OpenAI Services.
- (Optional) Visual Studio or Visual Studio Code: You will need an IDE or code editor capable of running .NET projects. Visual Studio or Visual Studio Code are recommended.
The following samples demonstrates differnet capabilities of the GPT-4o model, in example: analyzing and describing an image. The samples uses the official OpenAI library for .NET and Semantic Kernel to process the image and generate a description using C#.
Here is the list of projects:
Category | Name | Description | Source |
---|---|---|---|
Semantic Kernel | GPT4o_lab01 | Chat sample analizing an image from a URL | .\src\GPT4o_lab01 |
Semantic Kernel | GPT4o_lab02 | Audio to text sample | .\src\GPT4o_lab02 |
OpenAI library for .NET | OAINETSDK_lab01 | Chat sample asking questions to GPT-4o |
.\src\OAINETSDK_lab01 |
OpenAI library for .NET | OAINETSDK_lab02 | Audio to text using Whisper-1 |
.\src\OAINETSDK_lab02 |
OpenAI library for .NET | OAINETSDK_lab03 | Chat sample analizing an image from a local file with GPT-4o |
.\src\OAINETSDK_lab03 |
Category | Name | Description | Source |
---|---|---|---|
Semantic Kernel | GPT4o_AOAI_lab01 | Chat sample analizing an image from a URL | .\src\GPT4o_AOAI_lab01 |
Semantic Kernel | GPT4o_AOAI_lab02 | Upload an image to an Azure Blob and then analizes the image from the blob URL. | .\src\GPT4o_AOAI_lab02 |
To run the project, follow these steps:
-
Clone the repository to your local machine.
-
Open a terminal and enter your OpenAI Key with the following commands
cd .\src\GPT4o_lab01\ # init projecs user-secrets dotnet user-secrets init # add OpenAI API Key dotnet user-secrets set "APIKEY" "OpenAI API KEY"
-
Run the project with the command
dotnet run
-
The current project analyzes this image
-
You should see an output similar to this one:
The image shows a person holding a mug that has the text "Ultrarunning (verb) the art of running as far as you can, and then running another 20 miles." In the background, there is a scenic view of trees and lush greenery, along with an outdoor swimming pool surrounded by a paved deck with lounge chairs. Additionally, a dog is partially visible near the bottom right of the image, standing near the railing. The scene appears to be tranquil and picturesque, likely taking place in a backyard or a similar outdoor setting.
- Announcing the official OpenAI library for .NET
- What is Azure OpenAI Service?
- Quickstart: Azure Blob Storage client library for .NET
π€ Bruno Capuano
- Website: https://elbruno.com
- Twitter: @elbruno
- Github: @elbruno
- LinkedIn: @elbruno
Contributions, issues and feature requests are welcome!
Feel free to check issues page.
Give a βοΈ if this project helped you!
Copyright Β© 2024 Bruno Capuano.
This project is MIT licensed.