adamrushy / OpenAISwift

This is a wrapper library around the ChatGPT and OpenAI HTTP API
MIT License
1.6k stars 242 forks source link

change object property to be optional? #62

Closed a-elnajjar closed 1 year ago

a-elnajjar commented 1 year ago

I have this error when my client iOS App requests from the OpenAI endpoint

▿ Result<OpenAI, OpenAIError>

  ▿ failure : OpenAIError
    ▿ decodingError : 1 element
      ▿ error : DecodingError
        ▿ keyNotFound : 2 elements
          - .0 : CodingKeys(stringValue: "object", intValue: nil)
          ▿ .1 : Context
            - codingPath : 0 elements
            - debugDescription : "No value associated with key CodingKeys(stringValue: \"object\", intValue: nil) (\"object\")."
            - underlyingError : nil

I check the source code of struct OpenAI. can we make change the object to optional? the struct openAI should be like

public struct OpenAI<T: Payload>: Codable {
    public let object: String?
    public let model: String?
    public let choices: [T]
} 
adamrushy commented 1 year ago

Yeah it's incoming 👍🏼

a-elnajjar commented 1 year ago

thank you

GengJian commented 1 year ago
image

same problem T.T

GengJian commented 1 year ago

You can change SPM tag 1.2.0 -> branch Main

adamrushy commented 1 year ago

New release created which includes this change 👍🏼