49 lines
1.3 KiB
TypeScript
49 lines
1.3 KiB
TypeScript
|
|
import { writable } from 'svelte/store';
|
||
|
|
import { invoke } from '@tauri-apps/api/core';
|
||
|
|
|
||
|
|
export interface AppSettings {
|
||
|
|
ai_provider: string;
|
||
|
|
openai_api_key: string;
|
||
|
|
anthropic_api_key: string;
|
||
|
|
openai_model: string;
|
||
|
|
anthropic_model: string;
|
||
|
|
litellm_model: string;
|
||
|
|
local_model_path: string;
|
||
|
|
local_binary_path: string;
|
||
|
|
transcription_model: string;
|
||
|
|
transcription_device: string;
|
||
|
|
transcription_language: string;
|
||
|
|
skip_diarization: boolean;
|
||
|
|
}
|
||
|
|
|
||
|
|
const defaults: AppSettings = {
|
||
|
|
ai_provider: 'local',
|
||
|
|
openai_api_key: '',
|
||
|
|
anthropic_api_key: '',
|
||
|
|
openai_model: 'gpt-4o-mini',
|
||
|
|
anthropic_model: 'claude-sonnet-4-6',
|
||
|
|
litellm_model: 'gpt-4o-mini',
|
||
|
|
local_model_path: '',
|
||
|
|
local_binary_path: 'llama-server',
|
||
|
|
transcription_model: 'base',
|
||
|
|
transcription_device: 'cpu',
|
||
|
|
transcription_language: '',
|
||
|
|
skip_diarization: false,
|
||
|
|
};
|
||
|
|
|
||
|
|
export const settings = writable<AppSettings>({ ...defaults });
|
||
|
|
|
||
|
|
export async function loadSettings(): Promise<void> {
|
||
|
|
try {
|
||
|
|
const saved = await invoke<Record<string, unknown>>('load_settings');
|
||
|
|
settings.update(s => ({ ...s, ...saved } as AppSettings));
|
||
|
|
} catch {
|
||
|
|
// Use defaults if settings can't be loaded
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
export async function saveSettings(s: AppSettings): Promise<void> {
|
||
|
|
settings.set(s);
|
||
|
|
await invoke('save_settings', { settings: s });
|
||
|
|
}
|