Files
cutdex/lib/integrations/agent/agent_models.dart
T
lingjhf 27e77fff39 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.
2026-10-05 23:36:23 +08:00

70 lines
2.0 KiB
Dart

import 'package:cutdex_agent/cutdex_agent.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'agent_prompt_policy.dart';
part 'agent_models.freezed.dart';
enum AgentApiType { openAiChatCompletions, openAiResponses, anthropicMessages }
@freezed
abstract class AgentModelSettings with _$AgentModelSettings {
const AgentModelSettings._();
const factory AgentModelSettings({
required String id,
int? contextWindow,
int? maxOutputTokens,
}) = _AgentModelSettings;
/// Reserve at most half of a small window when output is unspecified.
int get effectiveMaxOutputTokens =>
maxOutputTokens ??
(contextWindow == null || contextWindow! >= 8192
? 4096
: contextWindow! ~/ 2);
int get effectiveMaxInputTokens =>
contextWindow == null ? 32000 : contextWindow! - effectiveMaxOutputTokens;
bool get hasInstructionBudget =>
effectiveMaxInputTokens >=
ContextBuilder().measureInput(system: AgentPromptPolicy.editorAssistant);
bool get hasValidTokenBudget =>
effectiveMaxInputTokens > 0 && effectiveMaxOutputTokens > 0;
}
@freezed
abstract class AgentProviderSettings with _$AgentProviderSettings {
const AgentProviderSettings._();
const factory AgentProviderSettings({
required String id,
required String name,
required String apiType,
required String baseUrl,
required List<AgentModelSettings> models,
String? credentialId,
@Default(true) bool enabled,
}) = _AgentProviderSettings;
}
@freezed
abstract class AgentSettingsState with _$AgentSettingsState {
const AgentSettingsState._();
const factory AgentSettingsState({
@Default(false) bool enabled,
@Default([]) List<AgentProviderSettings> providers,
String? selectedProviderId,
String? selectedModelId,
@Default(0) int revision,
}) = _AgentSettingsState;
}
abstract interface class AgentSettingsRepository {
Future<AgentSettingsState> load();
Future<void> save(AgentSettingsState settings);
}