feat: upgrade AI prompts to v2 specification with grounding and injection shield
This commit is contained in:
+19
@@ -0,0 +1,19 @@
|
||||
const AdmZip = require("adm-zip");
|
||||
function parseUDF(buffer) {
|
||||
try {
|
||||
const zip = new AdmZip(buffer);
|
||||
const zipEntries = zip.getEntries();
|
||||
const contentEntry = zipEntries.find((entry) => entry.entryName === "content.xml" || entry.entryName.endsWith(".xml"));
|
||||
if (!contentEntry) {
|
||||
throw new Error("No XML content found inside UDF/ZIP");
|
||||
}
|
||||
const xmlData = zip.readAsText(contentEntry);
|
||||
// Remove XML tags and replace with space, then replace multiple spaces with single space
|
||||
const plainText = xmlData.replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
|
||||
return plainText;
|
||||
} catch (err) {
|
||||
console.error("UDF parse error:", err);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
console.log("ok");
|
||||
Reference in New Issue
Block a user