1- import CodableWrappers
1+ @ preconcurrency import CodableWrappers
22import Foundation
33
44/// A chat message that can be sent or received.
5- public struct ChatMessage : Equatable , Codable {
5+ public struct ChatMessage : Equatable , Codable , Sendable {
66 public typealias ID = String
77
88 /// The role of a message.
9- public enum Role : String , Codable , Equatable {
9+ public enum Role : String , Codable , Equatable , Sendable {
1010 case system
1111 case user
1212 case assistant
@@ -15,7 +15,7 @@ public struct ChatMessage: Equatable, Codable {
1515 }
1616
1717 /// A function call that can be made by the bot.
18- public struct FunctionCall : Codable , Equatable {
18+ public struct FunctionCall : Codable , Equatable , Sendable {
1919 /// The name of the function.
2020 public var name : String
2121 /// Arguments in the format of a JSON string.
@@ -27,7 +27,7 @@ public struct ChatMessage: Equatable, Codable {
2727 }
2828
2929 /// A tool call that can be made by the bot.
30- public struct ToolCall : Codable , Equatable , Identifiable {
30+ public struct ToolCall : Codable , Equatable , Identifiable , Sendable {
3131 public var id : String
3232 /// The type of tool call.
3333 public var type : String
@@ -49,7 +49,7 @@ public struct ChatMessage: Equatable, Codable {
4949 }
5050
5151 /// The response of a tool call
52- public struct ToolCallResponse : Codable , Equatable {
52+ public struct ToolCallResponse : Codable , Equatable , Sendable {
5353 /// The content of the response.
5454 public var content : String
5555 /// The summary of the response to display in UI.
@@ -61,10 +61,10 @@ public struct ChatMessage: Equatable, Codable {
6161 }
6262
6363 /// A reference to include in a chat message.
64- public struct Reference : Codable , Equatable , Identifiable {
64+ public struct Reference : Codable , Equatable , Identifiable , Sendable {
6565 /// The kind of reference.
66- public enum Kind : Codable , Equatable {
67- public enum Symbol : String , Codable {
66+ public enum Kind : Codable , Equatable , Sendable {
67+ public enum Symbol : String , Codable , Sendable {
6868 case `class`
6969 case `struct`
7070 case `enum`
@@ -77,6 +77,7 @@ public struct ChatMessage: Equatable, Codable {
7777 case function
7878 case method
7979 }
80+
8081 /// Code symbol.
8182 case symbol( Symbol , uri: String , startLine: Int ? , endLine: Int ? )
8283 /// Some text.
@@ -138,10 +139,10 @@ public struct ChatMessage: Equatable, Codable {
138139
139140 /// The id of the message.
140141 public var id : ID
141-
142+
142143 /// The id of the sender of the message.
143144 public var senderId : String ?
144-
145+
145146 /// The id of the message that this message is a response to.
146147 public var responseTo : ID ?
147148
@@ -151,7 +152,7 @@ public struct ChatMessage: Equatable, Codable {
151152 /// The references of this message.
152153 @FallbackDecoding < EmptyArray < Reference > >
153154 public var references : [ Reference ]
154-
155+
155156 /// Cache the message in the prompt if possible.
156157 public var cacheIfPossible : Bool
157158
@@ -190,15 +191,15 @@ public struct ChatMessage: Equatable, Codable {
190191 }
191192}
192193
193- public struct ReferenceKindFallback : FallbackValueProvider {
194+ public struct ReferenceKindFallback : FallbackValueProvider , Sendable {
194195 public static var defaultValue : ChatMessage . Reference . Kind { . other( kind: " Unknown " ) }
195196}
196197
197- public struct ReferenceIDFallback : FallbackValueProvider {
198+ public struct ReferenceIDFallback : FallbackValueProvider , Sendable {
198199 public static var defaultValue : String { UUID ( ) . uuidString }
199200}
200201
201- public struct ChatMessageRoleFallback : FallbackValueProvider {
202+ public struct ChatMessageRoleFallback : FallbackValueProvider , Sendable {
202203 public static var defaultValue : ChatMessage . Role { . user }
203204}
204205
0 commit comments