diff --git a/Sources/OpenAI/Public/Models/ChatQuery.swift b/Sources/OpenAI/Public/Models/ChatQuery.swift index c7a88649..27079d93 100644 --- a/Sources/OpenAI/Public/Models/ChatQuery.swift +++ b/Sources/OpenAI/Public/Models/ChatQuery.swift @@ -110,24 +110,24 @@ public struct ChatQuery: Equatable, Codable, Streamable { public enum ChatCompletionMessageParam: Codable, Equatable { - case system(Self.ChatCompletionSystemMessageParam) - case user(Self.ChatCompletionUserMessageParam) - case assistant(Self.ChatCompletionAssistantMessageParam) - case tool(Self.ChatCompletionToolMessageParam) + case system(Self.SystemMessageParam) + case user(Self.UserMessageParam) + case assistant(Self.AssistantMessageParam) + case tool(Self.ToolMessageParam) - public var content: Self.ChatCompletionUserMessageParam.Content? { get { + public var content: Self.UserMessageParam.Content? { get { switch self { case .system(let systemMessage): - return Self.ChatCompletionUserMessageParam.Content.string(systemMessage.content) + return Self.UserMessageParam.Content.string(systemMessage.content) case .user(let userMessage): return userMessage.content case .assistant(let assistantMessage): if let content = assistantMessage.content { - return Self.ChatCompletionUserMessageParam.Content.string(content) + return Self.UserMessageParam.Content.string(content) } return nil case .tool(let toolMessage): - return Self.ChatCompletionUserMessageParam.Content.string(toolMessage.content) + return Self.UserMessageParam.Content.string(toolMessage.content) } }} @@ -166,7 +166,7 @@ public struct ChatQuery: Equatable, Codable, Streamable { } }} - public var toolCalls: [Self.ChatCompletionAssistantMessageParam.ChatCompletionMessageToolCallParam]? { get { + public var toolCalls: [Self.AssistantMessageParam.ToolCallParam]? { get { switch self { case .assistant(let assistantMessage): return assistantMessage.toolCalls @@ -179,7 +179,7 @@ public struct ChatQuery: Equatable, Codable, Streamable { role: Role, content: String? = nil, name: String? = nil, - toolCalls: [Self.ChatCompletionAssistantMessageParam.ChatCompletionMessageToolCallParam]? = nil, + toolCalls: [Self.AssistantMessageParam.ToolCallParam]? = nil, toolCallId: String? = nil ) { switch role { @@ -208,7 +208,7 @@ public struct ChatQuery: Equatable, Codable, Streamable { public init?( role: Role, - content: [ChatCompletionUserMessageParam.Content.VisionContent], + content: [UserMessageParam.Content.VisionContent], name: String? = nil ) { switch role { @@ -233,7 +233,7 @@ public struct ChatQuery: Equatable, Codable, Streamable { } private init?( - content: Self.ChatCompletionUserMessageParam.Content, + content: Self.UserMessageParam.Content, role: Role, name: String? = nil ) { @@ -248,7 +248,7 @@ public struct ChatQuery: Equatable, Codable, Streamable { role: Role, content: String? = nil, name: String? = nil, - toolCalls: [Self.ChatCompletionAssistantMessageParam.ChatCompletionMessageToolCallParam]? = nil + toolCalls: [Self.AssistantMessageParam.ToolCallParam]? = nil ) { if role == .assistant { self = .assistant(.init(content: content, name: name, toolCalls: toolCalls)) @@ -290,7 +290,7 @@ public struct ChatQuery: Equatable, Codable, Streamable { case tool } - public struct ChatCompletionSystemMessageParam: Codable, Equatable { + public struct SystemMessageParam: Codable, Equatable { public typealias Role = ChatQuery.ChatCompletionMessageParam.Role /// The contents of the system message. @@ -315,7 +315,7 @@ public struct ChatQuery: Equatable, Codable, Streamable { } } - public struct ChatCompletionUserMessageParam: Codable, Equatable { + public struct UserMessageParam: Codable, Equatable { public typealias Role = ChatQuery.ChatCompletionMessageParam.Role /// The contents of the user message. @@ -486,7 +486,7 @@ public struct ChatQuery: Equatable, Codable, Streamable { } } - public struct ChatCompletionAssistantMessageParam: Codable, Equatable { + public struct AssistantMessageParam: Codable, Equatable { public typealias Role = ChatQuery.ChatCompletionMessageParam.Role //// The role of the messages author, in this case assistant. @@ -496,12 +496,12 @@ public struct ChatQuery: Equatable, Codable, Streamable { /// 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? /// The tool calls generated by the model, such as function calls. - public let toolCalls: [Self.ChatCompletionMessageToolCallParam]? + public let toolCalls: [Self.ToolCallParam]? public init( content: String? = nil, name: String? = nil, - toolCalls: [Self.ChatCompletionMessageToolCallParam]? = nil + toolCalls: [Self.ToolCallParam]? = nil ) { self.content = content self.name = name @@ -515,7 +515,7 @@ public struct ChatQuery: Equatable, Codable, Streamable { case toolCalls = "tool_calls" } - public struct ChatCompletionMessageToolCallParam: Codable, Equatable { + public struct ToolCallParam: Codable, Equatable { public typealias ToolsType = ChatQuery.ChatCompletionToolParam.ToolsType /// The ID of the tool call. @@ -543,7 +543,7 @@ public struct ChatQuery: Equatable, Codable, Streamable { } } - public struct ChatCompletionToolMessageParam: Codable, Equatable { + public struct ToolMessageParam: Codable, Equatable { public typealias Role = ChatQuery.ChatCompletionMessageParam.Role /// The contents of the tool message. diff --git a/Sources/OpenAI/Public/Models/ChatResult.swift b/Sources/OpenAI/Public/Models/ChatResult.swift index c2f7c12d..5f718282 100644 --- a/Sources/OpenAI/Public/Models/ChatResult.swift +++ b/Sources/OpenAI/Public/Models/ChatResult.swift @@ -136,7 +136,7 @@ extension ChatQuery.ChatCompletionMessageParam { } } -extension ChatQuery.ChatCompletionMessageParam.ChatCompletionUserMessageParam.Content { +extension ChatQuery.ChatCompletionMessageParam.UserMessageParam.Content { public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() do {