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

Sample not working for Azure OpenAI - invalid request

Open jorisdg opened this issue 2 years ago • 1 comments

Describe the bug Trying to follow the basic example from: https://github.com/microsoft/semantic-kernel/blob/main/dotnet/README.md The code works with an OpenAI key, but if used with Azure OpenAI, I get an error 400 - invalid request.

To Reproduce Steps to reproduce the behavior:

  1. Follow https://github.com/microsoft/semantic-kernel/blob/main/dotnet/README.md
  2. Fill in the model deployment name, endpoint and Key
  3. Run the code

Expected behavior Receive the summary results

** Received behavior** Error: InvalidRequest: The request is not valid, HTTP status: 400 Error: InvalidRequest: The request is not valid, HTTP status: 400

Desktop (please complete the following information):

  • OS: Windows11
  • IDE: Visual Studio Enterpruse
  • NuGet Package Version : 0.13.277.1-preview
  • Project: C# console app

Additional context It's not an endpoint or auth problem as those results in 403 (tried the sample with the wrong key to make sure). Something in the API call to Azure OpenAI endpoint seems to have an issue. I double checked (copy/pasted) the model deployment name, the endpoint and the key directly from the Azure portal.

jorisdg avatar Apr 25 '23 22:04 jorisdg

Ok, I was able to get more details by debugging the result from SK... It looks like gpt-35-turbo doesn't support all the parameters SK is using. So I guess it's a documentation issue? I switched to davinci and that worked.

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: Tue, 25 Apr 2023 22:33:55 GMT Content-Length: 236 Content-Type: application/json

jorisdg avatar Apr 25 '23 22:04 jorisdg

you use the wrong model for TextCompletionService

if you want to use gpt-35-turbo model, you should use ChatCompletionService

https://github.com/microsoft/semantic-kernel/blob/main/samples/dotnet/kernel-syntax-examples/Example26_SemanticFunctionsUsingChatGPT.cs#L22

feiyun0112 avatar Apr 27 '23 04:04 feiyun0112

Can't believe I missed that! Switching to ChatCompletionService worked perfectly. Getting much better results with 35turbo on AOAI !! I think I have GPT4 on OAI so will try that next.

jorisdg avatar Apr 27 '23 16:04 jorisdg