From 6428470052039f582371d22277f4590620a19993 Mon Sep 17 00:00:00 2001 From: viktike Date: Mon, 27 Apr 2026 16:20:16 +0200 Subject: [PATCH] Refactor tool calls mapping to include index --- Sources/SwiftLM/Server.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sources/SwiftLM/Server.swift b/Sources/SwiftLM/Server.swift index 012d38d..d1298ac 100644 --- a/Sources/SwiftLM/Server.swift +++ b/Sources/SwiftLM/Server.swift @@ -1368,8 +1368,9 @@ func handleChatCompletion( case "assistant": var formattedToolCalls: [[String: any Sendable]]? = nil if let tc = msg.tool_calls, !tc.isEmpty { - formattedToolCalls = tc.map { call in + formattedToolCalls = tc.enumerated().map { (index, call) in [ + "index": index, "id": call.id, "type": call.type, "function": [