Skip to content

The open-source AI voice studio. Clone, dictate, create.

Wire settings pane to custom OpenAI-compatible LLM endpoint

Moroya Sakamotod1681484c13e
diff --git a/app/src/components/ServerTab/CapturesPage.tsx b/app/src/components/ServerTab/CapturesPage.tsx
index 48cd16a4..b26e3649 100644
--- a/app/src/components/ServerTab/CapturesPage.tsx
+++ b/app/src/components/ServerTab/CapturesPage.tsx
@@ -15,6 +15,7 @@ import {
DropdownMenuSeparator,
DropdownMenuTrigger,
} from '@/components/ui/dropdown-menu';
+import { Input } from '@/components/ui/input';
import {
Select,
SelectContent,
@@ -140,10 +141,51 @@ export function CapturesPage() {
const hotkeyEnabled = settings?.hotkey_enabled ?? false;
const pushToTalkKeys = settings?.chord_push_to_talk_keys ?? defaultChordKeys('push');
const toggleToTalkKeys = settings?.chord_toggle_to_talk_keys ?? defaultChordKeys('toggle');
+ const customLlmEndpointSaved = settings?.custom_llm_endpoint ?? '';
+ const customLlmModelSaved = settings?.custom_llm_model ?? '';
+ const customLlmApiKeySaved = settings?.custom_llm_api_key ?? '';
+ const customLlmActive = Boolean(customLlmEndpointSaved && customLlmModelSaved);
const [chordEditor, setChordEditor] = useState<'push' | 'toggle' | null>(null);
const [opening, setOpening] = useState(false);
const [capturesPath, setCapturesPath] = useState<string | null>(null);
+ // Drafts persist to the server on blur so we don't fire a PUT + optimistic
+ // re-render on every keystroke while the user types out a URL or token.
+ const [customLlmEndpointDraft, setCustomLlmEndpointDraft] = useState(customLlmEndpointSaved);
+ const [customLlmModelDraft, setCustomLlmModelDraft] = useState(customLlmModelSaved);
+ const [customLlmApiKeyDraft, setCustomLlmApiKeyDraft] = useState(customLlmApiKeySaved);
+
+ useEffect(() => {
+ setCustomLlmEndpointDraft(customLlmEndpointSaved);
+ }, [customLlmEndpointSaved]);
+ useEffect(() => {
+ setCustomLlmModelDraft(customLlmModelSaved);
+ }, [customLlmModelSaved]);
+ useEffect(() => {
+ setCustomLlmApiKeyDraft(customLlmApiKeySaved);
+ }, [customLlmApiKeySaved]);
+
+ const commitCustomLlmEndpoint = useCallback(() => {
+ const next = customLlmEndpointDraft.trim();
+ if (next !== customLlmEndpointSaved) {
+ update({ custom_llm_endpoint: next || null });
+ }
+ }, [customLlmEndpointDraft, customLlmEndpointSaved, update]);
+ const commitCustomLlmModel = useCallback(() => {
+ const next = customLlmModelDraft.trim();
+ if (next !== customLlmModelSaved) {
+ update({ custom_llm_model: next || null });
+ }
+ }, [customLlmModelDraft, customLlmModelSaved, update]);
+ const commitCustomLlmApiKey = useCallback(() => {
+ // The API key can legitimately contain leading/trailing punctuation for
+ // some providers, so we only trim when the whole field is whitespace.
+ const trimmed = customLlmApiKeyDraft.trim();
+ const next = trimmed ? customLlmApiKeyDraft : '';
+ if (next !== customLlmApiKeySaved) {
+ update({ custom_llm_api_key: next || null });
+ }
+ }, [customLlmApiKeyDraft, customLlmApiKeySaved, update]);
useEffect(() => {
fetch(`${serverUrl}/health/filesystem`)
@@ -453,6 +495,54 @@ export function CapturesPage() {
/>
}
/>
+
+ <SettingRow
+ title={t('settings.captures.refinement.customEndpoint.title')}
+ description={t('settings.captures.refinement.customEndpoint.description')}
+ >
+ <div className="space-y-2 max-w-lg">
+ <Input
+ id="customLlmEndpoint"
+ type="url"
+ placeholder={t('settings.captures.refinement.customEndpoint.endpointPlaceholder')}
+ value={customLlmEndpointDraft}
+ onChange={(e) => setCustomLlmEndpointDraft(e.target.value)}
+ onBlur={commitCustomLlmEndpoint}
+ disabled={!autoRefine}
+ autoComplete="off"
+ spellCheck={false}
+ />
+ <Input
+ id="customLlmModel"
+ type="text"
+ placeholder={t('settings.captures.refinement.customEndpoint.modelPlaceholder')}
+ value={customLlmModelDraft}
+ onChange={(e) => setCustomLlmModelDraft(e.target.value)}
+ onBlur={commitCustomLlmModel}
+ disabled={!autoRefine || !customLlmEndpointDraft}
+ autoComplete="off"
+ spellCheck={false}
+ />
+ <Input
+ id="customLlmApiKey"
+ type="password"
+ placeholder={t('settings.captures.refinement.customEndpoint.apiKeyPlaceholder')}
+ value={customLlmApiKeyDraft}
+ onChange={(e) => setCustomLlmApiKeyDraft(e.target.value)}
+ onBlur={commitCustomLlmApiKey}
+ disabled={!autoRefine || !customLlmEndpointDraft}
+ autoComplete="off"
+ spellCheck={false}
+ />
+ <p className="text-xs text-muted-foreground">
+ {customLlmActive
+ ? t('settings.captures.refinement.customEndpoint.statusRemote', {
+ endpoint: customLlmEndpointSaved,
+ })
+ : t('settings.captures.refinement.customEndpoint.statusBuiltin')}
+ </p>
+ </div>
+ </SettingRow>
</SettingSection>
<SettingSection
diff --git a/app/src/lib/api/types.ts b/app/src/lib/api/types.ts
index 457cf711..0357a6a5 100644
--- a/app/src/lib/api/types.ts
+++ b/app/src/lib/api/types.ts
@@ -217,6 +217,15 @@ export interface CaptureSettings {
chord_push_to_talk_keys: string[];
/** keytap key names. Toggle adds Space to the platform-specific PTT chord. */
chord_toggle_to_talk_keys: string[];
+ /**
+ * Optional OpenAI-compatible endpoint that overrides the built-in Qwen3
+ * LLM for refinement / personality rewriting. When set, backend calls hit
+ * `POST {custom_llm_endpoint}/chat/completions` with the model named by
+ * ``custom_llm_model``; leaving it null keeps the on-device Qwen path.
+ */
+ custom_llm_endpoint: string | null;
+ custom_llm_model: string | null;
+ custom_llm_api_key: string | null;
}
export type CaptureSettingsUpdate = Partial<CaptureSettings>;