@@ -91,7 +91,7 @@ class ChatMessageEx {
9191 * Extract the elements of the all in one tool call result string
9292 * @param {string } allInOne
9393 */
94- static extractToolCallResultAllInOne ( allInOne ) {
94+ static extractToolCallResultAllInOneSimpleMinded ( allInOne ) {
9595 const regex = / < t o o l _ r e s p o n s e > \s * < i d > ( .* ?) < \/ i d > \s * < n a m e > ( .* ?) < \/ n a m e > \s * < c o n t e n t > ( [ \s \S ] * ?) < \/ c o n t e n t > \s * < \/ t o o l _ r e s p o n s e > / si;
9696 const caught = allInOne . match ( regex )
9797 let data = { tool_call_id : "Error" , name : "Error" , content : "Error" }
@@ -105,6 +105,29 @@ class ChatMessageEx {
105105 return data
106106 }
107107
108+ /**
109+ * 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.
111+ * @param {string } allInOne
112+ */
113+ static extractToolCallResultAllInOne ( allInOne ) {
114+ const dParser = new DOMParser ( ) ;
115+ const got = dParser . parseFromString ( allInOne , 'text/xml' ) ;
116+ const parseErrors = got . querySelector ( 'parseerror' )
117+ if ( parseErrors ) {
118+ console . debug ( "WARN:ChatMessageEx:ExtractToolCallResultAllInOne:" , parseErrors . textContent . trim ( ) )
119+ }
120+ const id = got . querySelector ( 'id' ) ?. textContent . trim ( ) ;
121+ const name = got . querySelector ( 'name' ) ?. textContent . trim ( ) ;
122+ const content = got . querySelector ( 'content' ) ?. textContent . trim ( ) ;
123+ let data = {
124+ tool_call_id : id ? id : "Error" ,
125+ name : name ? name : "Error" ,
126+ content : content ? content : "Error"
127+ }
128+ return data
129+ }
130+
108131 /**
109132 * Set extra members into the ns object
110133 * @param {string | number } key
0 commit comments