aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/chatbot/utils/AgentDocumentManager.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/nodes/chatbot/utils/AgentDocumentManager.ts')
-rw-r--r--src/client/views/nodes/chatbot/utils/AgentDocumentManager.ts20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/client/views/nodes/chatbot/utils/AgentDocumentManager.ts b/src/client/views/nodes/chatbot/utils/AgentDocumentManager.ts
index 82b7ed3df..e9d41efbd 100644
--- a/src/client/views/nodes/chatbot/utils/AgentDocumentManager.ts
+++ b/src/client/views/nodes/chatbot/utils/AgentDocumentManager.ts
@@ -965,11 +965,21 @@ export class AgentDocumentManager {
* @returns An array of document IDs (strings).
*/
@computed
- public get listDocs(): string[] {
- console.log(
- Array.from(this.documentsById.entries()).map(([id, agentDoc]) => JSON.stringify({ id, title: agentDoc.layoutDoc.title, type: agentDoc.layoutDoc.type, summary: agentDoc.layoutDoc.summary || 'No summary available for this document.' }))
- );
- return Array.from(this.documentsById.entries()).map(([id, agentDoc]) => JSON.stringify({ id, title: agentDoc.layoutDoc.title, type: agentDoc.layoutDoc.type, summary: agentDoc.layoutDoc.summary || 'No summary available for this document.' }));
+ public get listDocs(): string {
+ const xmlDocs = Array.from(this.documentsById.entries()).map(([id, agentDoc]) => {
+ return `<document>
+ <id>${id}</id>
+ <title>${this.escapeXml(StrCast(agentDoc.layoutDoc.title))}</title>
+ <type>${this.escapeXml(StrCast(agentDoc.layoutDoc.type))}</type>
+ <summary>${this.escapeXml(StrCast(agentDoc.layoutDoc.summary))}</summary>
+</document>`;
+ });
+
+ return xmlDocs.join('\n');
+ }
+
+ private escapeXml(str: string): string {
+ return str.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&apos;');
}
@computed