Files
apidash/packages/genai/lib/models/model_config.dart
Ankit Mahato 72fea1ba65 Refactor genai package to new modular interface
Reorganized the genai package by removing legacy LLM-related files and introducing a new modular interface under the 'interface' directory. Added provider-specific model classes, centralized constants, and updated the example to use the new API and data structures. Updated exports in genai.dart and improved dependency management.
2025-08-27 02:08:36 +05:30

75 lines
1.5 KiB
Dart

import 'model_config_value.dart';
class ModelConfig {
final String id;
final String name;
final String description;
final ConfigType type;
final ConfigValue value;
ModelConfig({
required this.id,
required this.name,
required this.description,
required this.type,
required this.value,
}) {
assert(checkTypeValue(type, value));
}
ModelConfig updateValue(ConfigValue value) {
return ModelConfig(
id: id,
name: name,
description: description,
type: type,
value: value,
);
}
factory ModelConfig.fromJson(Map x) {
final id = x['id'] as String?;
final name = x['name'] as String?;
final description = x['description'] as String?;
final type = x['type'] as String?;
final value = x['value'] as String?;
final cT = getConfigTypeEnum(type);
final cV = deserilizeValue(cT, value);
return ModelConfig(
id: id ?? "",
name: name ?? "",
description: description ?? "",
type: cT,
value: cV,
);
}
Map<String, String?> toJson() {
return {
'id': id,
'name': name,
'description': description,
'type': type.name.toString(),
'value': value.serialize(),
};
}
ModelConfig copyWith({
String? id,
String? name,
String? description,
ConfigType? type,
ConfigValue? value,
}) {
return ModelConfig(
id: id ?? this.id,
name: name ?? this.name,
description: description ?? this.description,
type: type ?? this.type,
value: value ?? this.value,
);
}
}