File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ public struct ContentView: View {
51
51
52
52
func sendMessage (message : String ) {
53
53
Task {
54
- try ! await api.send (event : .createConversationItem (Item (message : .init (from : .user , content : [.text (message)]))))
54
+ try ! await api.send (event : .createConversationItem (Item (message : .init (id : " msg-1 " , from : .user , content : [.text (message)]))))
55
55
try ! await api.send (event : .createResponse ())
56
56
}
57
57
}
Original file line number Diff line number Diff line change @@ -141,7 +141,7 @@ public enum Item: Sendable {
141
141
}
142
142
143
143
/// The unique ID of the item.
144
- public var id : String ?
144
+ public var id : String
145
145
/// The type of the item
146
146
private var type : String = " message "
147
147
/// The status of the item
@@ -151,7 +151,7 @@ public enum Item: Sendable {
151
151
/// The content of the message.
152
152
public var content : [ Content ]
153
153
154
- public init ( id: String ? = nil , from role: ItemRole , content: [ Content ] ) {
154
+ public init ( id: String , from role: ItemRole , content: [ Content ] ) {
155
155
self . id = id
156
156
self . role = role
157
157
status = . completed
@@ -195,6 +195,17 @@ public enum Item: Sendable {
195
195
case functionCall( FunctionCall )
196
196
case functionCallOutput( FunctionCallOutput )
197
197
198
+ public var id : String {
199
+ switch self {
200
+ case let . message( message) :
201
+ return message. id
202
+ case let . functionCall( functionCall) :
203
+ return functionCall. id
204
+ case let . functionCallOutput( functionCallOutput) :
205
+ return functionCallOutput. id
206
+ }
207
+ }
208
+
198
209
public init ( message: Message ) {
199
210
self = . message( message)
200
211
}
You can’t perform that action at this time.
0 commit comments