feat: initial Cutdex application
Add the Flutter video editing application with project management, media import, timeline editing, preview, AI assistance, diagnostics and settings. Include shared UI and native host packages, platform runners, application tests and release tooling. Provide usage and contribution guides, the MIT license and third-party notices. Exclude local credentials, build outputs and validation data.
This commit is contained in:
commit
27e77fff39
718 files changed
+183958
No files matched your search
@@ -0,0 +1,101 @@
|
||||
import '../../integrations/agent/agent_models.dart';
|
||||
|
||||
import 'package:drift/drift.dart' hide JsonKey;
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
import '../app_database.dart';
|
||||
|
||||
part 'agent_settings_repository.g.dart';
|
||||
|
||||
@Riverpod(keepAlive: true)
|
||||
AgentSettingsRepository agentSettingsRepository(Ref ref) =>
|
||||
DriftAgentSettingsRepository(ref.watch(appDatabaseProvider));
|
||||
|
||||
class DriftAgentSettingsRepository implements AgentSettingsRepository {
|
||||
DriftAgentSettingsRepository(this._database);
|
||||
|
||||
final AppDatabase _database;
|
||||
|
||||
@override
|
||||
Future<AgentSettingsState> load() async {
|
||||
final configuration = await (_database.select(
|
||||
_database.agentConfigurations,
|
||||
)..where((table) => table.id.equals(0))).getSingleOrNull();
|
||||
final providerRows = await (_database.select(
|
||||
_database.agentProviders,
|
||||
)..orderBy([(table) => OrderingTerm.asc(table.name)])).get();
|
||||
final modelRows = await (_database.select(
|
||||
_database.agentModels,
|
||||
)..orderBy([(table) => OrderingTerm.asc(table.modelId)])).get();
|
||||
return AgentSettingsState(
|
||||
enabled: configuration?.enabled ?? false,
|
||||
selectedProviderId: configuration?.selectedProviderId,
|
||||
selectedModelId: configuration?.selectedModelId,
|
||||
revision: configuration?.revision ?? 0,
|
||||
providers: [
|
||||
for (final provider in providerRows)
|
||||
AgentProviderSettings(
|
||||
id: provider.id,
|
||||
enabled: provider.enabled,
|
||||
name: provider.name,
|
||||
apiType: provider.apiType,
|
||||
baseUrl: provider.baseUrl,
|
||||
credentialId: provider.credentialId,
|
||||
models: [
|
||||
for (final model in modelRows)
|
||||
if (model.providerId == provider.id)
|
||||
AgentModelSettings(
|
||||
id: model.modelId,
|
||||
contextWindow: model.contextWindow,
|
||||
maxOutputTokens: model.maxOutputTokens,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> save(AgentSettingsState settings) =>
|
||||
_database.transaction(() async {
|
||||
await _database.delete(_database.agentModels).go();
|
||||
await _database.delete(_database.agentProviders).go();
|
||||
for (final provider in settings.providers) {
|
||||
await _database
|
||||
.into(_database.agentProviders)
|
||||
.insert(
|
||||
AgentProvidersCompanion.insert(
|
||||
id: provider.id,
|
||||
enabled: Value(provider.enabled),
|
||||
name: provider.name,
|
||||
apiType: provider.apiType,
|
||||
baseUrl: provider.baseUrl,
|
||||
credentialId: Value(provider.credentialId),
|
||||
),
|
||||
);
|
||||
for (final model in provider.models) {
|
||||
await _database
|
||||
.into(_database.agentModels)
|
||||
.insert(
|
||||
AgentModelsCompanion.insert(
|
||||
providerId: provider.id,
|
||||
modelId: model.id,
|
||||
contextWindow: Value(model.contextWindow),
|
||||
maxOutputTokens: Value(model.maxOutputTokens),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
await _database
|
||||
.into(_database.agentConfigurations)
|
||||
.insertOnConflictUpdate(
|
||||
AgentConfigurationsCompanion.insert(
|
||||
id: const Value(0),
|
||||
enabled: settings.enabled,
|
||||
selectedProviderId: Value(settings.selectedProviderId),
|
||||
selectedModelId: Value(settings.selectedModelId),
|
||||
revision: settings.revision,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user