Skip to content

Commit

Permalink
It appears that OpenAI errors return a message field containing an ar…
Browse files Browse the repository at this point in the history
…ray, instead of a string, for example:

{  "error": {
    "message": [
      "Invalid schema for function 'get_n_day_weather_forecast': In context=('properties', 'format'), array schema missing items"
    ],
    "type": "invalid_request_error",
    "param": null,
    "code": null
  }
}

This causes the JSON deserializer to choke.

There doesn't seem to be an official API documentation for error messages. However, since they appear to be only used for user feedback, I'd propose changing their type to be an unspecified `object`.
  • Loading branch information
rzubek committed Jul 7, 2023
1 parent 012af71 commit 80bde47
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion OpenAI.SDK/ObjectModels/ResponseModels/BaseResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public record Error
{
[JsonPropertyName("code")] public string? Code { get; set; }

[JsonPropertyName("message")] public string? Message { get; set; }
[JsonPropertyName("message")] public object? Message { get; set; }

[JsonPropertyName("param")] public string? Param { get; set; }

Expand Down

1 comment on commit 80bde47

@kayhantolga
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.