diff --git a/Sources/OpenAI/Public/Parameters/Chat/ChatCompletionParameters.swift b/Sources/OpenAI/Public/Parameters/Chat/ChatCompletionParameters.swift index 24520b0..2ed5036 100644 --- a/Sources/OpenAI/Public/Parameters/Chat/ChatCompletionParameters.swift +++ b/Sources/OpenAI/Public/Parameters/Chat/ChatCompletionParameters.swift @@ -90,12 +90,16 @@ public struct ChatCompletionParameters: Encodable { public struct Message: Encodable { - /// The role of the messages author. One of system, user, assistant, or tool message. - public let role: String /// The contents of the message. content is required for all messages, and may be null for assistant messages with function calls. public let content: ContentType + /// The refusal message by the assistant. + public let refusal: String? + /// The role of the messages author. One of system, user, assistant, or tool message. + public let role: String /// The name of the author of this message. name is required if role is function, and it should be the name of the function whose response is in the content. May contain a-z, A-Z, 0-9, and underscores, with a maximum length of 64 characters. public let name: String? + /// Data about a previous audio response from the model. [Learn more.](https://platform.openai.com/docs/guides/audio) + public let audio: Audio? /// The name and arguments of a function that should be called, as generated by the model. @available(*, deprecated, message: "Deprecated and replaced by `tool_calls`") let functionCall: FunctionCall? @@ -222,10 +226,22 @@ public struct ChatCompletionParameters: Encodable { case tool // content, role, tool_call_id } + public struct Audio: Encodable { + + /// Unique identifier for a previous audio response from the model. + public let id: String + + public init(id: String) { + self.id = id + } + } + enum CodingKeys: String, CodingKey { case role case content + case refusal case name + case audio case functionCall = "function_call" case toolCalls = "tool_calls" case toolCallID = "tool_call_id" @@ -234,14 +250,18 @@ public struct ChatCompletionParameters: Encodable { public init( role: Role, content: ContentType, + refusal: String? = nil, name: String? = nil, + audio: Audio? = nil, functionCall: FunctionCall? = nil, toolCalls: [ToolCall]? = nil, toolCallID: String? = nil) { self.role = role.rawValue self.content = content + self.refusal = refusal self.name = name + self.audio = audio self.functionCall = functionCall self.toolCalls = toolCalls self.toolCallID = toolCallID diff --git a/Sources/OpenAI/Public/ResponseModels/Chat/ChatCompletionObject.swift b/Sources/OpenAI/Public/ResponseModels/Chat/ChatCompletionObject.swift index ceb6b35..25fa169 100644 --- a/Sources/OpenAI/Public/ResponseModels/Chat/ChatCompletionObject.swift +++ b/Sources/OpenAI/Public/ResponseModels/Chat/ChatCompletionObject.swift @@ -66,11 +66,11 @@ public struct ChatCompletionObject: Decodable { /// Unique identifier for this audio response. public let id: String /// The Unix timestamp (in seconds) for when this audio response will no longer be accessible on the server for use in multi-turn conversations. - public let expiresAt: Int + public let expiresAt: Int? /// Base64 encoded audio bytes generated by the model, in the format specified in the request. - public let data: String + public let data: String? /// Transcript of the audio generated by the model. - public let transcript: String + public let transcript: String? enum CodingKeys: String, CodingKey { case id