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

Bug: iOS - Content is null - 400 error

Open jerry2007 opened this issue 1 year ago • 4 comments
trafficstars

Describe the bug When I call one of method InvokePromptAsync/GetChatMessageContentsAsync/GetStreamingChatMessageContentsAsync on iOS. The error is raised.

Microsoft.SemanticKernel.HttpOperationException Invalid value for 'content': expected a string, got null. Status: 400 (model_error)

Content: { "error": { "message": "Invalid value for 'content': expected a string, got null.", "type": "invalid_request_error", "param": "messages.[0].content", "code": null } }

Headers: x-ms-region: REDACTED apim-request-id: REDACTED x-ratelimit-remaining-requests: REDACTED x-ms-rai-invoked: REDACTED X-Request-ID: REDACTED ms-azureml-model-error-reason: REDACTED ms-azureml-model-error-statuscode: REDACTED Strict-Transport-Security: REDACTED azureml-model-session: REDACTED X-Content-Type-Options: REDACTED x-envoy-upstream-service-time: REDACTED x-ms-client-request-id: 7f2d2543-dde4-45fc-87c3-934a33753cee x-ratelimit-remaining-tokens: REDACTED Date: Fri, 12 Jul 2024 07:42:46 GMT Content-Length: 187 Content-Type: application/json

To Reproduce Steps to reproduce the behavior:

  1. In Maui iOS call InvokePromptAsync/GetChatMessageContentsAsync/GetStreamingChatMessageContentsAsync
  2. See error

Expected behavior Can call these methods with no error

Platform

  • OS: iOS
  • IDE: Visual Studio
  • Language: C#
  • Source: NuGet package version 1.15.1

jerry2007 avatar Jul 12 '24 07:07 jerry2007

Hi @jerry2007 and thanks for filing this issue. Would you be able to share a snippet of the code that replicates this issue for us?

alliscode avatar Jul 15 '24 15:07 alliscode

` _history.AddUserMessage(question); OpenAIPromptExecutionSettings openAIPromptExecutionSettings = new() { ToolCallBehavior = ToolCallBehavior.AutoInvokeKernelFunctions, Temperature = 0.2 };

var answer = ""; await foreach (var result in _chatCompletionService.GetStreamingChatMessageContentsAsync( _history, executionSettings: openAIPromptExecutionSettings, kernel: _kernel, CancellationToken.None)) { answer += result?.Content; yield return result?.Content; }`

this code crash on line with foreach....

jerry2007 avatar Jul 24 '24 21:07 jerry2007

this is related: #6993

jerry2007 avatar Jul 24 '24 21:07 jerry2007

I found out that downgrade nuget Azure.AI.OpneAI to version 1.0.0-beta.15 in semnatic kernel project Connectors.OpenAI works correctly.

https://github.com/Azure/azure-sdk-for-net/issues/44174

jerry2007 avatar Aug 02 '24 15:08 jerry2007

Unfortunately, this issue not resolved in the latest versions. We use Structured Outputs which is not supported in earlier versions. :(

arafattehsin avatar Jan 09 '25 02:01 arafattehsin