Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

fix: pass custom system prompt to local and Anthropic BYOK reasoning

Gabriel Stein0c83010f69c1
diff --git a/src/components/ui/PromptStudio.tsx b/src/components/ui/PromptStudio.tsx
index 7d8c09359..0b499c3fd 100644
--- a/src/components/ui/PromptStudio.tsx
+++ b/src/components/ui/PromptStudio.tsx
@@ -163,28 +163,8 @@ export default function PromptStudio({ className = "" }: PromptStudioProps) {
localStorage.setItem("customUnifiedPrompt", JSON.stringify(editedPrompt));
try {
- if (reasoningProvider === "local") {
- const result = await window.electronAPI.processLocalReasoning(
- testText,
- reasoningModel,
- agentName,
- {}
- );
-
- if (result.success) {
- setTestResult(result.text || "");
- } else {
- setTestResult(`Local model error: ${result.error}`);
- }
- } else {
- const result = await ReasoningService.processText(
- testText,
- reasoningModel,
- agentName,
- {}
- );
- setTestResult(result);
- }
+ const result = await ReasoningService.processText(testText, reasoningModel, agentName, {});
+ setTestResult(result);
} finally {
if (currentCustomPrompt) {
localStorage.setItem("customUnifiedPrompt", currentCustomPrompt);
diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.js
index 7458f64ea..5e03a77e1 100644
--- a/src/helpers/ipcHandlers.js
+++ b/src/helpers/ipcHandlers.js
@@ -5,7 +5,6 @@ const https = require("https");
const crypto = require("crypto");
const AppUtils = require("../utils");
const debugLogger = require("./debugLogger");
-const { getSystemPrompt } = require("./prompts");
const GnomeShortcutManager = require("./gnomeShortcut");
const AssemblyAiStreaming = require("./assemblyAiStreaming");
@@ -24,14 +23,6 @@ class IPCHandlers {
this.setupHandlers();
}
- _getDictionarySafe() {
- try {
- return this.databaseManager.getDictionary();
- } catch {
- return [];
- }
- }
-
_syncStartupEnv(setVars, clearVars = []) {
let changed = false;
for (const [key, value] of Object.entries(setVars)) {
@@ -767,14 +758,10 @@ class IPCHandlers {
});
// Local reasoning handler
- ipcMain.handle("process-local-reasoning", async (event, text, modelId, agentName, config) => {
+ ipcMain.handle("process-local-reasoning", async (event, text, modelId, _agentName, config) => {
try {
const LocalReasoningService = require("../services/localReasoningBridge").default;
- const result = await LocalReasoningService.processText(text, modelId, agentName, {
- ...config,
- customDictionary: this._getDictionarySafe(),
- language: config?.language,
- });
+ const result = await LocalReasoningService.processText(text, modelId, config);
return { success: true, text: result };
} catch (error) {
return { success: false, error: error.message };
@@ -784,7 +771,7 @@ class IPCHandlers {
// Anthropic reasoning handler
ipcMain.handle(
"process-anthropic-reasoning",
- async (event, text, modelId, agentName, config) => {
+ async (event, text, modelId, _agentName, config) => {
try {
const apiKey = this.environmentManager.getAnthropicKey();
@@ -792,11 +779,7 @@ class IPCHandlers {
throw new Error("Anthropic API key not configured");
}
- const systemPrompt = getSystemPrompt(
- agentName,
- this._getDictionarySafe(),
- config?.language
- );
+ const systemPrompt = config?.systemPrompt || "";
const userPrompt = text;
if (!modelId) {
diff --git a/src/helpers/prompts.js b/src/helpers/prompts.js
deleted file mode 100644
index 69f35a9ff..000000000
--- a/src/helpers/prompts.js
+++ /dev/null
@@ -1,43 +0,0 @@
-const promptData = require("../config/promptData.json");
-const languageRegistry = require("../config/languageRegistry.json");
-
-const UNIFIED_SYSTEM_PROMPT = promptData.UNIFIED_SYSTEM_PROMPT;
-const DICTIONARY_SUFFIX = promptData.DICTIONARY_SUFFIX;
-
-const _langInstructions = Object.fromEntries(
- languageRegistry.languages.filter((l) => l.instruction).map((l) => [l.code, l.instruction])
-);
-
-function getLanguageInstruction(language) {
- if (!language || language === "en") return "";
- if (_langInstructions[language]) return _langInstructions[language];
- const template = languageRegistry._genericTemplate || "";
- return template.replace("{{code}}", language);
-}
-
-function getSystemPrompt(agentName, customDictionary, language) {
- const name = (agentName && agentName.trim()) || "Assistant";
- let prompt = UNIFIED_SYSTEM_PROMPT.replace(/\{\{agentName\}\}/g, name);
-
- const langInstruction = getLanguageInstruction(language);
- if (langInstruction) {
- prompt += "\n\n" + langInstruction;
- }
-
- if (Array.isArray(customDictionary) && customDictionary.length > 0) {
- prompt += DICTIONARY_SUFFIX + customDictionary.join(", ");
- }
-
- return prompt;
-}
-
-function buildPrompt(text, agentName) {
- const systemPrompt = getSystemPrompt(agentName);
- return `${systemPrompt}\n\n${text}`;
-}
-
-module.exports = {
- UNIFIED_SYSTEM_PROMPT,
- getSystemPrompt,
- buildPrompt,
-};
diff --git a/src/services/ReasoningService.ts b/src/services/ReasoningService.ts
index 5849e4956..79789e0dc 100644
--- a/src/services/ReasoningService.ts
+++ b/src/services/ReasoningService.ts
@@ -719,10 +719,10 @@ class ReasoningService extends BaseReasoningService {
textLength: text.length,
});
- const language = this.getPreferredLanguage();
+ const systemPrompt = this.getSystemPrompt(agentName);
const result = await window.electronAPI.processAnthropicReasoning(text, model, agentName, {
...config,
- language,
+ systemPrompt,
});
const processingTime = Date.now() - startTime;
@@ -770,10 +770,10 @@ class ReasoningService extends BaseReasoningService {
textLength: text.length,
});
- const language = this.getPreferredLanguage();
+ const systemPrompt = this.getSystemPrompt(agentName);
const result = await window.electronAPI.processLocalReasoning(text, model, agentName, {
...config,
- language,
+ systemPrompt,
});
const processingTime = Date.now() - startTime;
diff --git a/src/services/localReasoningBridge.js b/src/services/localReasoningBridge.js
index 1e8379208..fe12a5913 100644
--- a/src/services/localReasoningBridge.js
+++ b/src/services/localReasoningBridge.js
@@ -1,6 +1,5 @@
const modelManager = require("../helpers/modelManagerBridge").default;
const debugLogger = require("../helpers/debugLogger");
-const { getSystemPrompt } = require("../helpers/prompts");
class LocalReasoningService {
constructor() {
@@ -9,10 +8,7 @@ class LocalReasoningService {
async isAvailable() {
try {
- // Check if llama.cpp is installed
await modelManager.ensureLlamaCpp();
-
- // Check if at least one model is downloaded
const models = await modelManager.getAllModels();
return models.some((model) => model.isDownloaded);
} catch (error) {
@@ -20,10 +16,9 @@ class LocalReasoningService {
}
}
- async processText(text, modelId, agentName = null, config = {}) {
+ async processText(text, modelId, config = {}) {
debugLogger.logReasoning("LOCAL_BRIDGE_START", {
modelId,
- agentName,
textLength: text.length,
hasConfig: Object.keys(config).length > 0,
});
@@ -36,11 +31,6 @@ class LocalReasoningService {
const startTime = Date.now();
try {
- debugLogger.logReasoning("LOCAL_BRIDGE_PROMPT", {
- promptLength: text.length,
- hasAgentName: !!agentName,
- });
-
const inferenceConfig = {
maxTokens: config.maxTokens || this.calculateMaxTokens(text.length),
temperature: config.temperature || 0.7,
@@ -49,7 +39,7 @@ class LocalReasoningService {
repeatPenalty: config.repeatPenalty || 1.1,
contextSize: config.contextSize || 4096,
threads: config.threads || 4,
- systemPrompt: getSystemPrompt(agentName, config.customDictionary, config.language),
+ systemPrompt: config.systemPrompt || "",
};
debugLogger.logReasoning("LOCAL_BRIDGE_INFERENCE", {
@@ -57,7 +47,6 @@ class LocalReasoningService {
config: inferenceConfig,
});
- // Run inference
const result = await modelManager.runInference(modelId, text, inferenceConfig);
const processingTime = Date.now() - startTime;