Closed fabstu closed 1 year ago
Describe the bug An APIError associated with mishandling ChatGPT->Functions endpoint is not decoded correctly:
Failed to decode request: Optional("{\n \"error\": {\n \"message\": [\n \"Invalid schema for function \'hello\': In context=(\'properties\', \'a\'), array schema missing items\"\n ],\n \"type\": \"invalid_request_error\",\n \"param\": null,\n \"code\": null\n }\n}\n")
To Reproduce
let query = ChatQuery( model: .gpt3_5Turbo, messages: messages, functions: [ .init( name: "hello", description: "Hi", parameters: JSONSchema( type: .object, properties: [ "a": .init( type: .array, description: "A.", enumValues: [ "X", "Y" ] ), "b": .init( type: .string, description: "B.", enumValues: [ "T", ] ), ], required: ["b"] ) ) ] ) Self.logger.log("\n## Running request") let queryResponse = try await openAI.chats(query: query)
Expected behavior Decode error correctly.
Additional context I assume the issue is that the error message here is an array, while APIErrorResponse.message is of type String and does not handle decoding [String].
See https://github.com/MacPaw/OpenAI/pull/95 for a fix.
Describe the bug An APIError associated with mishandling ChatGPT->Functions endpoint is not decoded correctly:
To Reproduce
Expected behavior Decode error correctly.
Additional context I assume the issue is that the error message here is an array, while APIErrorResponse.message is of type String and does not handle decoding [String].