File tree Expand file tree Collapse file tree 1 file changed +3
-11
lines changed
Expand file tree Collapse file tree 1 file changed +3
-11
lines changed Original file line number Diff line number Diff line change @@ -109,7 +109,6 @@ public final class Chat: Sendable {
109109 break
110110 }
111111 }
112-
113112 return response
114113 }
115114
@@ -197,12 +196,7 @@ public final class Chat: Sendable {
197196 }
198197
199198 private func executeFunctionCalls( from content: ModelContent ) async throws -> ModelContent ? {
200- let functionCalls = content. parts. compactMap { part -> FunctionCall ? in
201- if let callPart = part as? FunctionCallPart {
202- return callPart. functionCall
203- }
204- return nil
205- }
199+ let functionCalls = content. parts. compactMap { ( $0 as? FunctionCallPart ) ? . functionCall }
206200
207201 if functionCalls. isEmpty {
208202 return nil
@@ -216,7 +210,7 @@ public final class Chat: Sendable {
216210 var functionResponses : [ FunctionResponsePart ] = [ ]
217211 var handledAny = false
218212
219- try await withThrowingTaskGroup ( of: FunctionResponsePart ? . self) { group in
213+ try await withThrowingTaskGroup ( of: FunctionResponsePart . self) { group in
220214 for call in functionCalls {
221215 if let handler = handlers [ call. name] {
222216 group. addTask {
@@ -228,9 +222,7 @@ public final class Chat: Sendable {
228222 }
229223
230224 for try await part in group {
231- if let part {
232- functionResponses. append ( part)
233- }
225+ functionResponses. append ( part)
234226 }
235227 }
236228
You can’t perform that action at this time.
0 commit comments