mirror of
https://github.com/block/goose.git
synced 2026-07-17 12:56:20 +02:00
53 lines
1.4 KiB
Swift
53 lines
1.4 KiB
Swift
//
|
|
// Message.swift
|
|
//
|
|
// Generated by openapi-generator
|
|
// https://openapi-generator.tech
|
|
//
|
|
|
|
import Foundation
|
|
#if canImport(AnyCodable)
|
|
import AnyCodable
|
|
#endif
|
|
|
|
/** A message to or from an LLM */
|
|
public struct Message: Codable, JSONEncodable, Hashable {
|
|
|
|
public var content: [MessageContent]
|
|
public var created: Int64?
|
|
public var id: String?
|
|
public var metadata: MessageMetadata?
|
|
public var role: String
|
|
|
|
public init(content: [MessageContent], created: Int64? = nil, id: String? = nil, metadata: MessageMetadata? = nil, role: String) {
|
|
self.content = content
|
|
self.created = created
|
|
self.id = id
|
|
self.metadata = metadata
|
|
self.role = role
|
|
}
|
|
|
|
public enum CodingKeys: String, CodingKey, CaseIterable {
|
|
case content
|
|
case created
|
|
case id
|
|
case metadata
|
|
case role
|
|
}
|
|
|
|
// Encodable protocol methods
|
|
|
|
public func encode(to encoder: Encoder) throws {
|
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
|
try container.encode(content, forKey: .content)
|
|
try container.encodeIfPresent(created, forKey: .created)
|
|
try container.encodeIfPresent(id, forKey: .id)
|
|
try container.encodeIfPresent(metadata, forKey: .metadata)
|
|
try container.encode(role, forKey: .role)
|
|
}
|
|
}
|
|
|
|
|
|
@available(iOS 13, tvOS 13, watchOS 6, macOS 10.15, *)
|
|
extension Message: Identifiable {}
|