feat(polish): add context safeguards, layered prompts, and output validation
Use redacted cursor neighborhood and pause-aware chunks for more natural polish, validate protected terms with retry/local fallback, and structure bilingual prompts for consistency and provider prefix caching.
This commit is contained in:
@@ -18,11 +18,15 @@ public enum TranslationPrompt {
|
||||
public static func make(
|
||||
target: TranslationLanguage,
|
||||
providerId: String,
|
||||
appContext: AppContext = .unknown
|
||||
appContext: AppContext = .unknown,
|
||||
sourceText: String = ""
|
||||
) -> String {
|
||||
let isChineseNative = ["zhipu", "moonshot", "qwen", "deepseek"].contains(providerId)
|
||||
let useChinese = PolishingService.shouldUseChineseGuidance(
|
||||
inputText: sourceText,
|
||||
providerId: providerId
|
||||
)
|
||||
let contextGuideline = appContext.polishGuideline
|
||||
return isChineseNative
|
||||
return useChinese
|
||||
? chinesePrompt(target: target, contextGuideline: contextGuideline)
|
||||
: englishPrompt(target: target, contextGuideline: contextGuideline)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user