11import CodableWrappers
22import Foundation
33
4+ /// A chat message that can be sent or received.
45public struct ChatMessage : Equatable , Codable {
56 public typealias ID = String
67
8+ /// The role of a message.
79 public enum Role : String , Codable , Equatable {
810 case system
911 case user
1012 case assistant
1113 }
1214
15+ /// A function call that can be made by the bot.
1316 public struct FunctionCall : Codable , Equatable {
17+ /// The name of the function.
1418 public var name : String
19+ /// Arguments in the format of a JSON string.
1520 public var arguments : String
1621 public init ( name: String , arguments: String ) {
1722 self . name = name
1823 self . arguments = arguments
1924 }
2025 }
2126
27+ /// A tool call that can be made by the bot.
2228 public struct ToolCall : Codable , Equatable , Identifiable {
2329 public var id : String
30+ /// The type of tool call.
2431 public var type : String
32+ /// The actual function call.
2533 public var function : FunctionCall
34+ /// The response of the function call.
2635 public var response : ToolCallResponse
2736 public init (
2837 id: String ,
@@ -37,16 +46,21 @@ public struct ChatMessage: Equatable, Codable {
3746 }
3847 }
3948
49+ /// The response of a tool call
4050 public struct ToolCallResponse : Codable , Equatable {
51+ /// The content of the response.
4152 public var content : String
53+ /// The summary of the response to display in UI.
4254 public var summary : String ?
4355 public init ( content: String , summary: String ? ) {
4456 self . content = content
4557 self . summary = summary
4658 }
4759 }
4860
61+ /// A reference to include in a chat message.
4962 public struct Reference : Codable , Equatable {
63+ /// The kind of reference.
5064 public enum Kind : Codable , Equatable {
5165 public enum Symbol : String , Codable {
5266 case `class`
@@ -61,36 +75,33 @@ public struct ChatMessage: Equatable, Codable {
6175 case function
6276 case method
6377 }
64- case symbol( Symbol )
78+ /// Code symbol.
79+ case symbol( Symbol , uri: String , startLine: Int ? , endLine: Int ? )
80+ /// Some text.
6581 case text
66- case webpage
67- case other( String )
82+ /// A webpage.
83+ case webpage( uri: String )
84+ /// A text file.
85+ case textFile( uri: String )
86+ /// Other kind of reference.
87+ case other( kind: String )
6888 }
6989
90+ /// The title of the reference.
7091 public var title : String
71- public var subTitle : String
72- public var uri : String
92+ /// The content of the reference.
7393 public var content : String
74- public var startLine : Int ?
75- public var endLine : Int ?
94+ /// The kind of the reference.
7695 @FallbackDecoding < ReferenceKindFallback >
7796 public var kind : Kind
7897
7998 public init (
8099 title: String ,
81- subTitle: String ,
82100 content: String ,
83- uri: String ,
84- startLine: Int ? = nil ,
85- endLine: Int ? = nil ,
86101 kind: Kind
87102 ) {
88103 self . title = title
89- self . subTitle = subTitle
90104 self . content = content
91- self . uri = uri
92- self . startLine = startLine
93- self . endLine = endLine
94105 self . kind = kind
95106 }
96107 }
@@ -167,7 +178,7 @@ public struct ChatMessage: Equatable, Codable {
167178}
168179
169180public struct ReferenceKindFallback : FallbackValueProvider {
170- public static var defaultValue : ChatMessage . Reference . Kind { . other( " Unknown " ) }
181+ public static var defaultValue : ChatMessage . Reference . Kind { . other( kind : " Unknown " ) }
171182}
172183
173184public struct ChatMessageRoleFallback : FallbackValueProvider {
0 commit comments