Skip to content

Commit

Permalink
Audio mulit turn
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesrochabrun committed Oct 28, 2024
1 parent f986986 commit 4895981
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down Expand Up @@ -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"
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4895981

Please sign in to comment.