1+ import CodableWrappers
12import Foundation
23
34struct Cancellable {
@@ -24,9 +25,32 @@ public struct ChatMessage: Equatable, Codable {
2425 }
2526 }
2627
28+ public struct Reference : Codable , Equatable {
29+ public var title : String
30+ public var subTitle : String
31+ public var uri : String
32+ public var startLine : Int ?
33+ public var endLine : Int ?
34+ public var metadata : [ String : String ]
35+
36+ public init (
37+ title: String ,
38+ subTitle: String ,
39+ uri: String ,
40+ startLine: Int ? ,
41+ endLine: Int ? ,
42+ metadata: [ String : String ]
43+ ) {
44+ self . title = title
45+ self . subTitle = subTitle
46+ self . uri = uri
47+ self . metadata = metadata
48+ }
49+ }
50+
2751 /// The role of a message.
2852 public var role : Role
29-
53+
3054 /// The content of the message, either the chat message, or a result of a function call.
3155 public var content : String ? {
3256 didSet { tokensCount = nil }
@@ -41,16 +65,20 @@ public struct ChatMessage: Equatable, Codable {
4165 public var name : String ? {
4266 didSet { tokensCount = nil }
4367 }
44-
68+
4569 /// The summary of a message that is used for display.
4670 public var summary : String ?
47-
71+
4872 /// The id of the message.
4973 public var id : String
50-
74+
5175 /// The number of tokens of this message.
5276 var tokensCount : Int ?
53-
77+
78+ /// The references of this message.
79+ @FallbackDecoding < EmptyArray < Reference > >
80+ public var references : [ Reference ]
81+
5482 /// Is the message considered empty.
5583 var isEmpty : Bool {
5684 if let content, !content. isEmpty { return false }
@@ -66,7 +94,8 @@ public struct ChatMessage: Equatable, Codable {
6694 name: String ? = nil ,
6795 functionCall: FunctionCall ? = nil ,
6896 summary: String ? = nil ,
69- tokenCount: Int ? = nil
97+ tokenCount: Int ? = nil ,
98+ references: [ Reference ] = [ ]
7099 ) {
71100 self . role = role
72101 self . content = content
@@ -75,6 +104,7 @@ public struct ChatMessage: Equatable, Codable {
75104 self . summary = summary
76105 self . id = id
77106 tokensCount = tokenCount
107+ self . references = references
78108 }
79109}
80110
0 commit comments