Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.
JavaScript aianthropiccross-platformgeminigroqlinuxmacosnvidiaopen-sourceopenaiparakeetspeech-to-texttranscribewhisperwindows
Detect llama.cpp via /v1/models and prefer /chat/completions
Skrumpy0c30341a1537
diff --git a/src/services/ReasoningService.ts b/src/services/ReasoningService.tsindex 13f829cc8..e3e78c5b1 100644--- a/src/services/ReasoningService.ts+++ b/src/services/ReasoningService.ts@@ -203,6 +203,63 @@ class ReasoningService extends BaseReasoningService {} catch {}}+ /**+ * Probe /v1/models to detect servers (notably llama.cpp's llama-server) that+ * respond 200 to /v1/responses but perform ~100 MiB of state serialization per+ * request, producing 5-29s latency vs 1-4s on /v1/chat/completions. Since the+ * 404-fallback in processWithOpenAI never triggers for llama.cpp (it returns+ * 200, not 404), proactively set the "chat" preference before the first call.+ *+ * Fail-closed: probe failure leaves the existing two-candidate selection+ * (/responses then /chat/completions) unchanged. No-op if preference already+ * stored for this base URL or if base already points at a fully-qualified+ * endpoint.+ */+ private async detectReasoningServerType(base: string): Promise<void> {+ if (this.getStoredOpenAiPreference(base) !== undefined) {+ return;+ }++ const lower = base.toLowerCase();+ if (lower.endsWith("/responses") || lower.endsWith("/chat/completions")) {+ return;+ }++ try {+ const controller = new AbortController();+ const timeoutId = setTimeout(() => controller.abort(), 2000);+ const res = await fetch(buildApiUrl(base, "/models"), {+ method: "GET",+ signal: controller.signal,+ });+ clearTimeout(timeoutId);++ if (!res.ok) {+ return;+ }++ const body = await res.json();+ const first = body?.data?.[0];+ const ownedBy = typeof first?.owned_by === "string" ? first.owned_by : undefined;+ const hasMeta =+ first && typeof first === "object" && "meta" in first && first.meta !== undefined;+ const isLlamaCpp = ownedBy === "llamacpp" || hasMeta;++ if (isLlamaCpp) {+ this.rememberOpenAiPreference(base, "chat");+ logger.logReasoning("LLAMACPP_DETECTED_VIA_MODELS", {+ base,+ modelId: typeof first?.id === "string" ? first.id : undefined,+ ownedBy,+ hasMeta,+ });+ }+ } catch {+ // Swallow probe errors; we fall through to the existing candidate+ // selection so behavior on unreachable/OpenAI/other servers is unchanged.+ }+ }+private async getApiKey(provider: "openai" | "anthropic" | "gemini" | "groq" | "custom"): Promise<string> {@@ -545,6 +602,7 @@ class ReasoningService extends BaseReasoningService {];const openAiBase = this.getConfiguredOpenAIBase();+ await this.detectReasoningServerType(openAiBase);const endpointCandidates = this.getOpenAIEndpointCandidates(openAiBase);const isCustomEndpoint = openAiBase !== API_ENDPOINTS.OPENAI_BASE;