-
Notifications
You must be signed in to change notification settings - Fork 210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
System.ClientModel.ClientResultException: 'HTTP 400 (invalid_request_error: ) #30
Comments
@joseharriaga Anyone from the OpenAI team who could have a look at this issue pls? Its a show stopper |
@trrwilson: Is this related to the issue that Chris and you were seeing with Mono? |
Almost certainly the same issue, yes. There's an oddity with how serialization covariance is handled on Mono with The problem is well understood, but we should consider expediting the workaround (of using virtual methods for these abstract serialization paths) in the interim. |
Experiencing this as well. Let me know if I can try/test anything to work towards a fix. |
Same issue here on Blazor WASM. As a temporary workaround, you can use: var json = BinaryData.FromObjectAsJson(new
{
model = "gpt-3.5-turbo",
messages = new[]
{
new
{
role = "user",
content ="YOUR_PROMPT"
}
}
});
var clientResult = await chatClient.CompleteChatAsync(BinaryContent.Create(json));
var chatCompletion = ModelReaderWriter.Read<ChatCompletion>(clientResult.GetRawResponse().Content, new("W")); |
To update; we've filed an issue with the .NET runtime team (thanks to @chschrae for investigating) to track the full fix for the underlying issue causing this problem: We're evaluating a mitigation option to unblock mono/wasm/etc. in the interim. |
@trrwilson, thanks a ton for the fix, it indeed was an issue with the generic interface across different runtimes. Appreciate the team's prompt intervention |
I am using the following code in a .NET Standard 2.0 project within a Xamarin.Forms Solution
string _model = "gpt-3.5-turbo";
_openAI_Client = new ChatClient(model: _model, _apiKey);
ChatCompletion chatCompletion = await _openAI_Client.CompleteChatAsync(new ChatMessage[] {
new UserChatMessage("Deep Reinforcement Learning for Finance")
});
however I am receiving the following exception on the execution of CompleteChatAsync()
System.ClientModel.ClientResultException: 'HTTP 400 (invalid_request_error: )
Parameter: messages.[0].content
Invalid value for 'content': expected a string, got null.'
The text was updated successfully, but these errors were encountered: