Improve diff editing prompts to avoid common deepseek issues

This commit is contained in:
Saoud Rizwan committed 2024-12-28 13:21:12 -08:00
1 parent f4b0887f60
commit f770487695
4 files changed
+60 -33

No files matched your search

+22
View File
@@ -0,0 +1,22 @@
/**
* Fixes incorrectly escaped HTML entities in AI model outputs
* @param text String potentially containing incorrectly escaped HTML entities from AI models
* @returns String with HTML entities converted back to normal characters
*/
export function fixModelHtmlEscaping(text: string): string {
return text
.replace(/>/g, ">")
.replace(/&lt;/g, "<")
.replace(/&quot;/g, '"')
.replace(/&amp;/g, "&")
.replace(/&apos;/g, "'")
}
/**
* Removes invalid characters (like the replacement character �) from a string
* @param text String potentially containing invalid characters
* @returns String with invalid characters removed
*/
export function removeInvalidChars(text: string): string {
return text.replace(/\uFFFD/g, "")
}