You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have tested the behavior of new response_format parameter implemented with #114. However, my frontend code always returned a JSON decoding error.
I traced from the breakpoint and found that it catches the error at this line in the method performRequest<ResultType: Codable>() of OpenAI.swift. Errors seems to occur when anything but a specific JSON structure (e.g. plain text) is entered.
Serialized data is also returned as UTF-8 plain text
JSON structure seems to have several patterns (e.g. Verbose JSON)
I tried all formats in the new enum AudioResponseFormat and found that only .json worked fine, text, Verbose JSON, srt and vtt caught any errors.
✅ AudioResponseFormat.json
❌ AudioResponseFormat.text
❌ AudioResponseFormat.verboseJson
❌ AudioResponseFormat.srt
❌ AudioResponseFormat.vtt
I have not tried testing with the AudioTranslations API, but it may contain same problems.
Error example 1
APIErrorResponse(error: OpenAI.APIError(message: "1 validation error for Request\nbody -> response_format\n value is not a valid enumeration member; permitted: 'json', 'text', 'vtt', 'srt', 'verbose_json' (type=type_error.enum; enum_values=[<ResponseFormat.JSON: 'json'>, <ResponseFormat.TEXT: 'text'>, <ResponseFormat.VTT: 'vtt'>, <ResponseFormat.SRT: 'srt'>, <ResponseFormat.VERBOSE_JSON: 'verbose_json'>])", type: "invalid_request_error", param: nil, code: nil))
Error example 2
dataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data was not valid JSON.", underlyingError: Optional(Error Domain=NSCocoaErrorDomain Code=3840 "Unexpected character 'W' around line 1, column 1." UserInfo={NSDebugDescription=Unexpected character 'W' around line 1, column 1., NSJSONSerializationErrorIndex=0})))
Expected behavior
Correctly decode returned data as JSON or plain text (including vtt, srt).
Desktop (please complete the following information):
OS: macOS
Version 14.1.1
The text was updated successfully, but these errors were encountered:
Describe the bug
I have tested the behavior of new
response_format
parameter implemented with #114. However, my frontend code always returned a JSON decoding error.I traced from the breakpoint and found that it catches the error at this line in the method
performRequest<ResultType: Codable>()
ofOpenAI.swift
. Errors seems to occur when anything but a specific JSON structure (e.g. plain text) is entered.I tried all formats in the new enum
AudioResponseFormat
and found that only.json
worked fine, text, Verbose JSON, srt and vtt caught any errors.AudioResponseFormat.json
AudioResponseFormat.text
AudioResponseFormat.verboseJson
AudioResponseFormat.srt
AudioResponseFormat.vtt
I have not tried testing with the AudioTranslations API, but it may contain same problems.
Error example 1
Error example 2
Expected behavior
Correctly decode returned data as JSON or plain text (including vtt, srt).
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: