diff --git a/apps/server/src/textGeneration/TranscriptionPostProcessing.test.ts b/apps/server/src/textGeneration/TranscriptionPostProcessing.test.ts index 5aa480bc7fe62..e8fb9f9ace9c7 100644 --- a/apps/server/src/textGeneration/TranscriptionPostProcessing.test.ts +++ b/apps/server/src/textGeneration/TranscriptionPostProcessing.test.ts @@ -1,8 +1,22 @@ +import { DEFAULT_SPEECH_POST_PROCESSING_PROMPT } from "@t3tools/contracts"; import { describe, expect, it } from "vite-plus/test"; import { buildTranscriptionPostProcessingPrompt } from "./TranscriptionPostProcessing.ts"; describe("buildTranscriptionPostProcessingPrompt", () => { + it.each([ + { mode: "default", instructions: DEFAULT_SPEECH_POST_PROCESSING_PROMPT }, + { mode: "custom", instructions: "Clean up my dictation." }, + ])("requires the structured transcription reply with $mode instructions", ({ instructions }) => { + const prompt = buildTranscriptionPostProcessingPrompt(instructions, "hello world", { + text: "", + selection: { start: 0, end: 0 }, + }); + expect(prompt).toContain( + 'Return a JSON object with one key, "transcription", holding the cleaned transcript.', + ); + }); + it("names the correction cue only when the person set one", () => { const draft = { text: "Make it 42.", selection: { start: 11, end: 11 } }; const plain = buildTranscriptionPostProcessingPrompt("Clean.", "sorry 24", draft); diff --git a/apps/server/src/textGeneration/TranscriptionPostProcessing.ts b/apps/server/src/textGeneration/TranscriptionPostProcessing.ts index 2bf48ad962a84..d4b892186cdd9 100644 --- a/apps/server/src/textGeneration/TranscriptionPostProcessing.ts +++ b/apps/server/src/textGeneration/TranscriptionPostProcessing.ts @@ -29,7 +29,7 @@ export function buildTranscriptionPostProcessingPrompt( ${transcript} -${placement} Use the composer draft and insertion position to resolve ambiguity and correct likely recognition errors in the transcript. The draft can clarify the topic, references, terminology, and how the new speech fits with nearby text. Prefer an interpretation supported by the draft when the speech plausibly matches it. Do not invent content, change clear speech, or include existing composer text in the result. Return only the cleaned transcript. +${placement} Use the composer draft and insertion position to resolve ambiguity and correct likely recognition errors in the transcript. The draft can clarify the topic, references, terminology, and how the new speech fits with nearby text. Prefer an interpretation supported by the draft when the speech plausibly matches it. Do not invent content, change clear speech, or include existing composer text in the result. Return only the cleaned transcript. Return a JSON object with one key, "transcription", holding the cleaned transcript. ${draft.text.slice(0, cursor)} ${selectionBlock}