| | without any CSS styling. STRICTLY AVOID any markdown table syntax. HTML Table should NEVER BE fenced with (\`\`\`html) triple backticks.
5. Replace any obvious placeholders or Lorem Ipsum values such as "example.com" with the actual content derived from the knowledge.
6. Your output language must be the same as user input language.
The following knowledge items are provided for your reference. Note that some of them may not be directly related to the content user provided, but may give some subtle hints and insights:
${KnowledgeStr.join('\n\n')}
IMPORTANT: Do not begin your response with phrases like "Sure", "Here is", "Below is", or any other introduction. Directly output your revised content in ${schema.languageStyle} that is ready to be published. Preserving HTML tables if exist, never use tripple backticks html to wrap html table.`,
user: mdContent
}
}
const TOOL_NAME = 'mdFixer';
export async function reviseAnswer(
mdContent: string,
knowledgeItems: KnowledgeItem[],
trackers: TrackerContext,
schema: Schemas
): Promise {
try {
const prompt = getPrompt(mdContent, knowledgeItems, schema);
trackers?.actionTracker.trackThink('final_answer', schema.languageCode)
const result = await generateText({
model: getModel(TOOL_NAME),
system: prompt.system,
prompt: prompt.user,
});
trackers.tokenTracker.trackUsage(TOOL_NAME, result.usage)
console.log(TOOL_NAME, result.text);
console.log('repaired before/after', mdContent.length, result.text.length);
if (result.text.length < mdContent.length * 0.85) {
console.error(`repaired content length ${result.text.length} is significantly shorter than original content ${mdContent.length}, return original content instead.`);
return mdContent;
}
return result.text;
} catch (error) {
console.error(`Error in ${TOOL_NAME}`, error);
return mdContent;
}
} |