65 lines
1.5 KiB
Dart
65 lines
1.5 KiB
Dart
import 'dart:io';
|
|
import 'package:hive_ce/hive.dart';
|
|
|
|
part 'ai_settings.g.dart';
|
|
|
|
@HiveType(typeId: 9)
|
|
class AiSettings extends HiveObject {
|
|
@HiveField(0)
|
|
String? apiKey;
|
|
|
|
@HiveField(1)
|
|
String baseUrl;
|
|
|
|
@HiveField(2)
|
|
String defaultModel;
|
|
|
|
@HiveField(3)
|
|
int timeoutSeconds;
|
|
|
|
@HiveField(4)
|
|
double temperature;
|
|
|
|
@HiveField(5)
|
|
int maxTokens;
|
|
|
|
@HiveField(6)
|
|
bool isEnabled;
|
|
|
|
AiSettings({
|
|
this.apiKey,
|
|
String? baseUrl,
|
|
String? defaultModel,
|
|
this.timeoutSeconds = 30,
|
|
this.temperature = 0.7,
|
|
this.maxTokens = 1000,
|
|
this.isEnabled = false,
|
|
}) : baseUrl = baseUrl ?? 'https://openrouter.ai/api/v1',
|
|
defaultModel = defaultModel ?? Platform.environment['AI_DEFAULT_MODEL'] ?? 'google/gemini-2.5-flash';
|
|
|
|
AiSettings copyWith({
|
|
String? apiKey,
|
|
String? baseUrl,
|
|
String? defaultModel,
|
|
int? timeoutSeconds,
|
|
double? temperature,
|
|
int? maxTokens,
|
|
bool? isEnabled,
|
|
}) {
|
|
return AiSettings(
|
|
apiKey: apiKey ?? this.apiKey,
|
|
baseUrl: baseUrl ?? this.baseUrl,
|
|
defaultModel: defaultModel ?? this.defaultModel,
|
|
timeoutSeconds: timeoutSeconds ?? this.timeoutSeconds,
|
|
temperature: temperature ?? this.temperature,
|
|
maxTokens: maxTokens ?? this.maxTokens,
|
|
isEnabled: isEnabled ?? this.isEnabled,
|
|
);
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return 'AiSettings(baseUrl: $baseUrl, defaultModel: $defaultModel, timeoutSeconds: $timeoutSeconds, temperature: $temperature, maxTokens: $maxTokens, isEnabled: $isEnabled)';
|
|
}
|
|
}
|