feat(chat): Add usage statistics support for message persistence

This commit is contained in:
cogwheel0
2025-12-15 18:42:06 +05:30
parent c21e70396d
commit 55cedc3ab8
7 changed files with 505 additions and 41 deletions

View File

@@ -156,6 +156,12 @@ sealed class Model with _$Model {
}
}
// Extract usage capability from info.meta.capabilities (OpenWebUI format)
// This indicates whether the model supports stream_options.include_usage
final infoMetaCapabilities =
infoMeta?['capabilities'] as Map<String, dynamic>?;
final supportsUsage = infoMetaCapabilities?['usage'] == true;
// Fallback to top-level toolIds (for cached models serialized via toJson)
if (toolIds == null || toolIds.isEmpty) {
final topLevelToolIds = json['toolIds'];
@@ -199,6 +205,7 @@ sealed class Model with _$Model {
'pricing': json['pricing'],
'context_length': json['context_length'],
'supported_parameters': supportedParamsList ?? supportedParams,
'usage': supportsUsage,
},
metadata: mergedMetadata,
toolIds: toolIds,