UNPKG

dadeumi

Version:

Dadeumi - An AI-powered literary translation workflow inspired by the Korean method of iterative textile refinement

57 lines (56 loc) 2.78 kB
/** * Translation Continuation Utilities * Functions for detecting incomplete translations and handling continuation */ interface ContinuationCheckResponse { continue: boolean; targetLastLine?: string; sourceLine?: string; } /** * Check if a translation is complete by using GPT-4o-mini in JSON mode * @param sourceText The original source text * @param translationText The current (potentially incomplete) translation * @param apiKey OpenAI API key (optional, will use env var if not provided) * @returns Object with continuation info or null if check failed */ export declare function checkTranslationCompletion(sourceText: string, translationText: string, verbose?: boolean, apiKey?: string): Promise<ContinuationCheckResponse | null>; /** * Creates a continuation prompt to ask the model to continue from a specific line * @param sourceText The full source text * @param partialTranslation The partial translation so far * @param targetLastLine The last line of the translation to continue from * @param sourceLine The corresponding source line * @returns A prompt for the model to continue the translation */ export declare function createContinuationPrompt(sourceText: string, partialTranslation: string, targetLastLine: string, sourceLine: string): string; /** * Saves a backup of the current partial translation before attempting to continue * @param filePath Path to the current translation file * @param backupDir Directory to store backups * @returns Path to the backup file or null if backup failed */ export declare function backupPartialTranslation(filePath: string, backupDir?: string): string | null; /** * Combines the partial translation with the continuation * @param partialTranslation The partial translation text * @param continuationText The continuation text from the model * @param targetLastLine The last line to match for replacement * @returns The combined translation or null if match failed */ export declare function combineTranslation(partialTranslation: string, continuationText: string, targetLastLine: string): string | null; /** * Remove unpaired XML tags from text (tags that are opened but not closed, or closed but not opened) */ export declare function removeUnpairedXmlTags(text: string): string; /** * Remove common "to be continued" markers from the end of text */ export declare function removeContinuationMarkers(text: string): string; /** * Creates a simple "please continue" prompt that preserves the existing conversation context * @param targetLastLine The last line of the truncated response to continue from * @returns A prompt asking the model to continue from where it left off */ export declare function createSimpleContinuationPrompt(targetLastLine: string): string; export {};