@@ -59,7 +59,7 @@ public struct ChatMessage: Equatable, Codable {
5959 }
6060
6161 /// A reference to include in a chat message.
62- public struct Reference : Codable , Equatable {
62+ public struct Reference : Codable , Equatable , Identifiable {
6363 /// The kind of reference.
6464 public enum Kind : Codable , Equatable {
6565 public enum Symbol : String , Codable {
@@ -89,6 +89,8 @@ public struct ChatMessage: Equatable, Codable {
8989 case error
9090 }
9191
92+ @FallbackDecoding < ReferenceIDFallback >
93+ public var id : String
9294 /// The title of the reference.
9395 public var title : String
9496 /// The content of the reference.
@@ -98,10 +100,12 @@ public struct ChatMessage: Equatable, Codable {
98100 public var kind : Kind
99101
100102 public init (
103+ id: String = UUID ( ) . uuidString,
101104 title: String ,
102105 content: String ,
103106 kind: Kind
104107 ) {
108+ self . id = id
105109 self . title = title
106110 self . content = content
107111 self . kind = kind
@@ -188,6 +192,10 @@ public struct ReferenceKindFallback: FallbackValueProvider {
188192 public static var defaultValue : ChatMessage . Reference . Kind { . other( kind: " Unknown " ) }
189193}
190194
195+ public struct ReferenceIDFallback : FallbackValueProvider {
196+ public static var defaultValue : String { UUID ( ) . uuidString }
197+ }
198+
191199public struct ChatMessageRoleFallback : FallbackValueProvider {
192200 public static var defaultValue : ChatMessage . Role { . user }
193201}
0 commit comments