The sk-csharp-console-chat
console application demonstrates how to use the Semantic Kernel OpenAI chat completion service.
- .NET 6 is required to run this starter.
- Install the recommended extensions
The starter can be configured by using either:
- Enter secrets at the command line with .NET Secret Manager
- Enter secrets in appsettings.json
For Debugging the console application alone, we suggest using .NET Secret Manager to avoid the risk of leaking secrets into the repository, branches and pull requests.
Using .NET Secret Manager
Configure an OpenAI endpoint
cd sk-csharp-console-chat
dotnet user-secrets set "serviceType" "OpenAI"
dotnet user-secrets set "serviceId" "gpt-3.5-turbo"
dotnet user-secrets set "modelId" "gpt-3.5-turbo"
dotnet user-secrets set "apiKey" "... your OpenAI key ..."
Configure an Azure OpenAI endpoint
cd sk-csharp-console-chat
dotnet user-secrets set "serviceType" "AzureOpenAI"
dotnet user-secrets set "serviceId" "gpt-35-turbo"
dotnet user-secrets set "deploymentId" "gpt-35-turbo"
dotnet user-secrets set "modelId" "gpt-3.5-turbo"
dotnet user-secrets set "endpoint" "https:// ... your endpoint ... .openai.azure.com/"
dotnet user-secrets set "apiKey" "... your Azure OpenAI key ..."
Configure the Semantic Kernel logging level
dotnet user-secrets set "LogLevel" 0
Log levels:
- 0 = Trace
- 1 = Debug
- 2 = Information
- 3 = Warning
- 4 = Error
- 5 = Critical
- 6 = None
Configure an OpenAI endpoint
- Copy settings.json.openai-example to
./config/appsettings.json
- Edit the file to add your OpenAI endpoint configuration
Configure an Azure OpenAI endpoint
- Copy settings.json.azure-example to
./config/appsettings.json
- Edit the file to add your Azure OpenAI endpoint configuration
To run the console application just hit F5
.
To build and run the console application from the terminal use the following commands:
dotnet build
dotnet run