feat: enhance model and tools integration with auto-selection functionality
- Added a new `toolIds` field to the `Model` class to support tool identification. - Implemented `modelToolsAutoSelectionProvider` to automatically apply model-specific tools when the selected model changes. - Enhanced the logic to filter and set valid tool IDs based on available tools, improving user experience by ensuring relevant tools are automatically selected. - Updated the default model auto-selection provider to initialize the new tools auto-selection feature, ensuring seamless integration within the app's lifecycle.
This commit is contained in:
@@ -16,6 +16,7 @@ sealed class Model with _$Model {
|
||||
Map<String, dynamic>? capabilities,
|
||||
Map<String, dynamic>? metadata,
|
||||
List<String>? supportedParameters,
|
||||
List<String>? toolIds,
|
||||
}) = _Model;
|
||||
|
||||
factory Model.fromJson(Map<String, dynamic> json) {
|
||||
@@ -111,6 +112,18 @@ sealed class Model with _$Model {
|
||||
mergedMetadata['info'] = {...existingInfo, ...infoSection};
|
||||
}
|
||||
|
||||
// Extract toolIds from info.meta.toolIds (OpenWebUI format)
|
||||
List<String>? toolIds;
|
||||
final infoMeta = (infoSection?['meta'] as Map<String, dynamic>?) ??
|
||||
(metaSection) ??
|
||||
(mergedMetadata['meta'] as Map<String, dynamic>?);
|
||||
if (infoMeta != null) {
|
||||
final toolIdsData = infoMeta['toolIds'];
|
||||
if (toolIdsData is List) {
|
||||
toolIds = toolIdsData.map((e) => e.toString()).toList();
|
||||
}
|
||||
}
|
||||
|
||||
return Model(
|
||||
id: json['id'] as String,
|
||||
name: json['name'] as String,
|
||||
@@ -126,6 +139,7 @@ sealed class Model with _$Model {
|
||||
'supported_parameters': supportedParamsList ?? supportedParams,
|
||||
},
|
||||
metadata: mergedMetadata,
|
||||
toolIds: toolIds,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user