Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ericstj/imageGeneratorSample

Repository files navigation

AI Chat with Custom Data

This project is an AI chat application that demonstrates how to chat with custom data using an AI language model. Please note that this template is currently in an early preview stage. If you have feedback, please take a brief survey.

Note

Before running this project you need to configure the API keys or endpoints for the providers you have chosen. See below for details specific to your choices.

Known Issues

Errors running Ollama or Docker

A recent incompatibility was found between Ollama and Docker Desktop. This issue results in runtime errors when connecting to Ollama, and the workaround for that can lead to Docker not working for Aspire projects.

This incompatibility can be addressed by upgrading to Docker Desktop 4.41.1. See ollama/ollama#9509 for more information and a link to install the version of Docker Desktop with the fix.

Configure the AI Model Provider

Using Azure OpenAI

To use Azure OpenAI, you will need an Azure account and an Azure OpenAI Service resource. For detailed instructions, see the Azure OpenAI Service documentation.

1. Create an Azure OpenAI Service Resource

Create an Azure OpenAI Service resource.

2. Deploy the Models

Deploy the gpt-4o-mini and text-embedding-3-small models to your Azure OpenAI Service resource. When creating those deployments, give them the same names as the models (gpt-4o-mini and text-embedding-3-small). See the Azure OpenAI documentation to learn how to Deploy a model.

3. Configure API Key and Endpoint

Configure your Azure OpenAI API key and endpoint for this project, using .NET User Secrets:

  1. In the Azure Portal, navigate to your Azure OpenAI resource.

  2. Copy the "Endpoint" URL and "Key 1" from the "Keys and Endpoint" section.

  3. From the command line, configure your API key and endpoint for this project using .NET User Secrets by running the following commands:

    cd imageGeneratorSample.AppHost
    dotnet user-secrets set ConnectionStrings:openai "Endpoint=https://YOUR-DEPLOYMENT-NAME.openai.azure.com;Key=YOUR-API-KEY"

Make sure to replace YOUR-API-KEY and YOUR-DEPLOYMENT-NAME with your actual Azure OpenAI key and endpoint. Make sure your endpoint URL is formatted like https://YOUR-DEPLOYMENT-NAME.openai.azure.com/ (do not include any path after .openai.azure.com/).

Running the application

Using Visual Studio

  1. Open the .sln file in Visual Studio.
  2. Press Ctrl+F5 or click the "Start" button in the toolbar to run the project.

Using Visual Studio Code

  1. Open the project folder in Visual Studio Code.
  2. Install the C# Dev Kit extension for Visual Studio Code.
  3. Once installed, Open the Program.cs file in the imageGeneratorSample.AppHost project.
  4. Run the project by clicking the "Run" button in the Debug view.

Trust the localhost certificate

Several .NET Aspire templates include ASP.NET Core projects that are configured to use HTTPS by default. If this is the first time you're running the project, an exception might occur when loading the Aspire dashboard. This error can be resolved by trusting the self-signed development certificate with the .NET CLI.

See Troubleshoot untrusted localhost certificate in .NET Aspire for more information.

Updating JavaScript dependencies

This template leverages JavaScript libraries to provide essential functionality. These libraries are located in the wwwroot/lib folder of the imageGeneratorSample.Web project. For instructions on updating each dependency, please refer to the README.md file in each respective folder.

Learn More

To learn more about development with .NET and AI, check out the following links:

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published