semantic-kernel icon indicating copy to clipboard operation
semantic-kernel copied to clipboard

Sample Kernel Http Server /api/skills/funskill/invoke/joke - BadRequest logprobs, best_of and echo parameters are not available on gpt-35-turbo model.

Open wanermiranda opened this issue 2 years ago • 5 comments

Describe the bug Considering the AzureOpenAI account and the gpt-35-turbo model. When executing the /api/skills/funskill/invoke/joke the kernel is returning the following message.

InvalidRequest: The request is not valid, HTTP status: 400 - Detail: logprobs, best_of and echo parameters are not available on gpt-35-turbo model. Please remove the parameter and try again. For more details, see https://go.microsoft.com/fwlink/?linkid=2227346.
Status: 400 (BadRequest)
ErrorCode: BadRequest

Content:
{"error":{"code":"BadRequest","message":"logprobs, best_of and echo parameters are not available on gpt-35-turbo model. Please remove the parameter and try again. For more details, see https://go.microsoft.com/fwlink/?linkid=2227346."}}

Headers:
apim-request-id: REDACTED
Strict-Transport-Security: REDACTED
X-Content-Type-Options: REDACTED
x-ms-region: REDACTED
Date: Fri, 21 Apr 2023 03:15:59 GMT
Content-Length: 236
Content-Type: application/json

I saw there was a similar problem in the past when using the GPT.

To Reproduce

curl 'http://localhost:7071/api/skills/funskill/invoke/joke' \
  -H 'Accept: */*' \
  -H 'Accept-Language: en-GB,en;q=0.9,en-US;q=0.8,pt;q=0.7' \
  -H 'Connection: keep-alive' \
  -H 'Content-Type: text/plain;charset=UTF-8' \
  -H 'Origin: http://localhost:3000' \
  -H 'Referer: http://localhost:3000/' \
  -H 'Sec-Fetch-Dest: empty' \
  -H 'Sec-Fetch-Mode: cors' \
  -H 'Sec-Fetch-Site: same-site' \
  -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36 Edg/112.0.1722.48' \
  -H 'sec-ch-ua: "Chromium";v="112", "Microsoft Edge";v="112", "Not:A-Brand";v="99"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "Windows"' \
  -H 'x-ms-sk-completion-backend: 0' \
  -H 'x-ms-sk-completion-endpoint: XXXXXXXX' \
  -H 'x-ms-sk-completion-key: XXXXXXXXX' \
  -H 'x-ms-sk-completion-model: completion-model' \
  --data-raw '{"value":"clippy","inputs":[{"key":"style","value":"Bill & Ted"}]}' \
  --compressed

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Windows 11
  • IDE: Visual Studio 2022
  • NuGet Package Version
   <TargetFramework>net6.0</TargetFramework>
   <AzureFunctionsVersion>v4</AzureFunctionsVersion>
   <OutputType>Exe</OutputType>
   <LangVersion>10</LangVersion>
   <Nullable>enable</Nullable>
   <ImplicitUsings>disable</ImplicitUsings>
   <IsPackable>false</IsPackable>
 </PropertyGroup>

 <ItemGroup>
   <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.0.13" />
   <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.9.0" OutputItemType="Analyzer" />
   <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.13.0" />
   <PackageReference Include="Microsoft.Graph" Version="4.54.0" />
 </ItemGroup>

wanermiranda avatar Apr 21 '23 03:04 wanermiranda

Thank you for the report, we are in the process of cleaning up the earlier samples to default to chat completion endpoints. Currently they expect text completion endpoints.

Two options:

  1. Use text-davinci-003

OR

  1. Change this line in KernelHttpServer: https://github.com/microsoft/semantic-kernel/blob/77259db3e352db64be4b5f08f5c11a391a101e60/samples/dotnet/KernelHttpServer/SemanticKernelFactory.cs#L55

The change would look like this:

c.AddAzureChatCompletionService(config.CompletionConfig.ServiceId, config.CompletionConfig.DeploymentOrModelId,
                        config.CompletionConfig.Endpoint,
                        config.CompletionConfig.Key, 
                        true);

craigomatic avatar Apr 21 '23 17:04 craigomatic

Thank you @craigomatic :)

wanermiranda avatar Apr 21 '23 23:04 wanermiranda

The second option when adding a new parameter, the signature does not match the code. error CS1501: No overload for method 'AddAzureTextCompletionService' takes 5 arguments

wanermiranda avatar Apr 21 '23 23:04 wanermiranda

Try with AddAzureChatCompletionService

craigomatic avatar Apr 21 '23 23:04 craigomatic

My mistake, tks. It worked like charm! Do you want to close this or will you we use it to create a PR?

wanermiranda avatar Apr 21 '23 23:04 wanermiranda

Lets close this for now, we will take care of all the samples in a future effort. Thanks for trying SK :)

craigomatic avatar Apr 24 '23 23:04 craigomatic