Skip to content

Commit 9441798

Browse files
committed
SimpleChatTC:ToolCall response relaxed handling
Use DOMParser parseFromString in text/html mode rather than text/xml as it makes it more relaxed without worrying about special chars of xml like & etal
1 parent 9bd3b35 commit 9441798

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

tools/server/public_simplechat/simplechat.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,18 @@ class ChatMessageEx {
107107

108108
/**
109109
* Extract the elements of the all in one tool call result string
110-
* This should potentially account for content tag having xml content within to an extent.
110+
* This should potentially account for content tag having xml/html content within to an extent.
111+
*
112+
* NOTE: Rather text/html is a more relaxed/tolarent mode for parseFromString than text/xml.
113+
* NOTE: Maybe better to switch to a json string format or use a more intelligent xml encoder
114+
* in createToolCallResultAllInOne so that extractor like this dont have to worry about special
115+
* xml chars like & as is, in the AllInOne content. For now text/html tolarence seems ok enough.
116+
*
111117
* @param {string} allInOne
112118
*/
113119
static extractToolCallResultAllInOne(allInOne) {
114120
const dParser = new DOMParser();
115-
const got = dParser.parseFromString(allInOne, 'text/xml');
121+
const got = dParser.parseFromString(allInOne, 'text/html');
116122
const parseErrors = got.querySelector('parseerror')
117123
if (parseErrors) {
118124
console.debug("WARN:ChatMessageEx:ExtractToolCallResultAllInOne:", parseErrors.textContent.trim())

0 commit comments

Comments
 (0)