Skip to content

Commit

Permalink
update readmes and add endpoint type
Browse files Browse the repository at this point in the history
  • Loading branch information
hario90 committed Aug 31, 2023
1 parent 97e6706 commit 1d5f08c
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 3 deletions.
14 changes: 14 additions & 0 deletions sk-csharp-azure-functions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,17 @@ To build and run the Azure Functions application from a terminal use the followi
dotnet build
func start --csharp
```

## Troubleshooting

### Getting a 400 (BadRequest) and error "Azure.RequestFailedException: logprobs, best_of and echo parameters are not available on gpt-35-turbo model. Please remove the parameter and try again."

A chat completion model (gpt-35-turbo) was set in serviceId/deploymentOrModelId while the kernel was configured to use a text completion model. The type of model used by the kernel can be configured with the endpointType secret. To fix, you can either:

- change endpointType to chat-completion

```powershell
dotnet user-secrets set "endpointType" "chat-completion"
```

- change serviceId and deploymentOrModelId to a text completion service like "text-davinci-003": [See Using .NET Secret Manager](#using-net-secret-manager).
5 changes: 5 additions & 0 deletions sk-csharp-azure-functions/config/EndpointTypes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
internal static class EndpointTypes
{
internal const string TextCompletion = "text-completion";
internal const string ChatCompletion = "chat-completion";
}
18 changes: 16 additions & 2 deletions sk-csharp-azure-functions/config/KernelBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,25 @@ internal static KernelBuilder WithCompletionService(this KernelBuilder kernelBui
switch (kernelSettings.ServiceType.ToUpperInvariant())
{
case ServiceTypes.AzureOpenAI:
kernelBuilder.WithAzureTextCompletionService(deploymentName: kernelSettings.DeploymentOrModelId, endpoint: kernelSettings.Endpoint, apiKey: kernelSettings.ApiKey, serviceId: kernelSettings.ServiceId);
if (kernelSettings.EndpointType == EndpointTypes.TextCompletion)
{
kernelBuilder.WithAzureTextCompletionService(deploymentName: kernelSettings.DeploymentOrModelId, endpoint: kernelSettings.Endpoint, apiKey: kernelSettings.ApiKey, serviceId: kernelSettings.ServiceId);
}
else if (kernelSettings.EndpointType == EndpointTypes.ChatCompletion)
{
kernelBuilder.WithAzureChatCompletionService(deploymentName: kernelSettings.DeploymentOrModelId, endpoint: kernelSettings.Endpoint, apiKey: kernelSettings.ApiKey, serviceId: kernelSettings.ServiceId);
}
break;

case ServiceTypes.OpenAI:
kernelBuilder.WithOpenAITextCompletionService(modelId: kernelSettings.DeploymentOrModelId, apiKey: kernelSettings.ApiKey, orgId: kernelSettings.OrgId, serviceId: kernelSettings.ServiceId);
if (kernelSettings.EndpointType == EndpointTypes.TextCompletion)
{
kernelBuilder.WithOpenAITextCompletionService(modelId: kernelSettings.DeploymentOrModelId, apiKey: kernelSettings.ApiKey, orgId: kernelSettings.OrgId, serviceId: kernelSettings.ServiceId);
}
else if (kernelSettings.EndpointType == EndpointTypes.ChatCompletion)
{
kernelBuilder.WithOpenAIChatCompletionService(modelId: kernelSettings.DeploymentOrModelId, apiKey: kernelSettings.ApiKey, orgId: kernelSettings.OrgId, serviceId: kernelSettings.ServiceId);
}
break;

default:
Expand Down
3 changes: 3 additions & 0 deletions sk-csharp-azure-functions/config/KernelSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ internal class KernelSettings
{
public const string DefaultConfigFile = "config/appsettings.json";

[JsonPropertyName("endpointType")]
public string EndpointType { get; set; } = EndpointTypes.TextCompletion;

[JsonPropertyName("serviceType")]
public string ServiceType { get; set; } = string.Empty;

Expand Down
2 changes: 1 addition & 1 deletion sk-csharp-chatgpt-plugin/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Semantic Kernel ChatGPT plugin starter

This project provides starter code to create a ChatGPT plugin. It includes the following components:

- An endpoint that serves up an ai-plugin.json file for ChatGPT to discover the plugin
- A generator that automatically converts prompts into semantic function endpoints
- The ability to add additional native functions as endpoints to the plugin
Expand All @@ -24,7 +25,6 @@ To configure the starter, you need to provide the following information:

For Debugging the console application alone, we suggest using .NET [Secret Manager](https://learn.microsoft.com/en-us/aspnet/core/security/app-secrets) to avoid the risk of leaking secrets into the repository, branches and pull requests.


### Using appsettings.json

Configure an OpenAI endpoint
Expand Down
14 changes: 14 additions & 0 deletions sk-csharp-hello-world/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,17 @@ To build and run the console application from the terminal use the following com
dotnet build
dotnet run
```

## Troubleshooting

### Getting a 400 (BadRequest) and error "Azure.RequestFailedException: logprobs, best_of and echo parameters are not available on gpt-35-turbo model. Please remove the parameter and try again."

A chat completion model (gpt-35-turbo) was set in serviceId/deploymentOrModelId while the kernel was configured to use a text completion model. The type of model used by the kernel can be configured with the endpointType secret. To fix, you can either:

- change endpointType to chat-completion

```powershell
dotnet user-secrets set "endpointType" "chat-completion"
```

- change serviceId and deploymentOrModelId to a text completion service like "text-davinci-003": [See Using .NET Secret Manager](#using-net-secret-manager).

0 comments on commit 1d5f08c

Please sign in to comment.