From 00a1b410397677c3d38abc0f66375611ebc322bc Mon Sep 17 00:00:00 2001 From: Kyle Hickinson Date: Thu, 26 Mar 2026 15:33:26 -0400 Subject: [PATCH] [iOS] [AIChat] Support tools for custom models (#34944) This adds a new toggle to the custom model form to allow the user to control whether or not the local modal supports tools --- ios/brave-ios/Sources/AIChat/AIChatStrings.swift | 14 ++++++++++++++ .../AIChat/WebUI/AIChatCustomModelForm.swift | 9 +++++++++ 2 files changed, 23 insertions(+) diff --git a/ios/brave-ios/Sources/AIChat/AIChatStrings.swift b/ios/brave-ios/Sources/AIChat/AIChatStrings.swift index ea94a3c141b..7c05cb90b90 100644 --- a/ios/brave-ios/Sources/AIChat/AIChatStrings.swift +++ b/ios/brave-ios/Sources/AIChat/AIChatStrings.swift @@ -1203,6 +1203,20 @@ extension Strings { value: "If this model takes image as input, e.g. llama 3.2b vision", comment: "The description text explaining what vision support means with an example" ) + public static let customModelFormSupportsToolsFieldTitle = NSLocalizedString( + "aichat.customModelFormToolsSupportFieldTitle", + tableName: "BraveLeo", + bundle: .module, + value: "Tools support", + comment: "The label for the tools support toggle" + ) + public static let customModelFormSupportsToolsFieldDescription = NSLocalizedString( + "aichat.customModelFormToolsSupportFieldDescription", + tableName: "BraveLeo", + bundle: .module, + value: "If this model supports function calling/tool use", + comment: "The description text explaining what tools supports means" + ) public static let customModelFormSystemPromptFieldTitle = NSLocalizedString( "aichat.customModelFormSystemPromptFieldTitle", tableName: "BraveLeo", diff --git a/ios/brave-ios/Sources/AIChat/WebUI/AIChatCustomModelForm.swift b/ios/brave-ios/Sources/AIChat/WebUI/AIChatCustomModelForm.swift index bb6ae76f8e2..86aadf8974d 100644 --- a/ios/brave-ios/Sources/AIChat/WebUI/AIChatCustomModelForm.swift +++ b/ios/brave-ios/Sources/AIChat/WebUI/AIChatCustomModelForm.swift @@ -30,6 +30,7 @@ struct CustomModelForm: View { var apiKey: String? var systemPrompt: String? var visionSupport: Bool = false + var supportsTools: Bool = false var isRequiredDataFilled: Bool { return !displayName.isEmpty && !requestName.isEmpty && !serverEndpoint.isEmpty @@ -200,6 +201,12 @@ struct CustomModelForm: View { } .tint(Color(braveSystemName: .primary40)) .listRowBackground(Color(.secondaryBraveGroupedBackground)) + Toggle(isOn: $data.supportsTools) { + Text(Strings.AIChat.customModelFormSupportsToolsFieldTitle) + Text(Strings.AIChat.customModelFormSupportsToolsFieldDescription) + } + .tint(Color(braveSystemName: .primary40)) + .listRowBackground(Color(.secondaryBraveGroupedBackground)) } Section { @@ -253,6 +260,7 @@ struct CustomModelForm: View { if let initialModel { data.displayName = initialModel.displayName data.visionSupport = initialModel.visionSupport + data.supportsTools = initialModel.supportsTools if let customOptions = initialModel.options.customModelOptions { data.requestName = customOptions.modelRequestName data.serverEndpoint = customOptions.endpoint.absoluteString @@ -311,6 +319,7 @@ struct CustomModelForm: View { } let model = AiChat.Model() model.visionSupport = data.visionSupport + model.supportsTools = data.supportsTools model.displayName = data.displayName model.options = .init( customModelOptions: .init(