[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
This commit is contained in:
Kyle Hickinson
2026-03-26 15:33:26 -04:00
committed by GitHub
parent 78a11e9d93
commit 00a1b41039
2 changed files with 23 additions and 0 deletions
@@ -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",
@@ -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(