@@ -329,6 +329,67 @@ async function fetchpdftext_setup(tcs) {
329329}
330330
331331
332+ //
333+ // Fetch XML Text
334+ //
335+
336+
337+ let fetchxmltext_meta = {
338+ "type" : "function" ,
339+ "function" : {
340+ "name" : "fetch_xml_as_text" ,
341+ "description" : "Fetch the requested xml url through a proxy server and return its text content after stripping away the xml tags, in few seconds" ,
342+ "parameters" : {
343+ "type" : "object" ,
344+ "properties" : {
345+ "url" :{
346+ "type" :"string" ,
347+ "description" :"url of the xml file that will be fetched"
348+ } ,
349+ "tagDrops" :{
350+ "type" :"string" ,
351+ "description" :"specify a json stringified form of list of xml tags to drop"
352+ }
353+ } ,
354+ "required" : [ "url" ]
355+ }
356+ }
357+ }
358+
359+
360+ /**
361+ * Implementation of the fetch xml as text logic.
362+ * Expects simpleproxy to be running at specified url and providing xmltext service
363+ * ALERT: Accesses a seperate/external web proxy/caching server, be aware and careful
364+ * @param {string } chatid
365+ * @param {string } toolcallid
366+ * @param {string } toolname
367+ * @param {any } obj
368+ */
369+ function fetchxmltext_run ( chatid , toolcallid , toolname , obj ) {
370+ let headers = { 'xmltext-tag-drops' : obj . tagDrops }
371+ return proxyserver_get_anyargs ( chatid , toolcallid , toolname , obj , 'xmltext' , headers ) ;
372+ }
373+
374+
375+ /**
376+ * Setup fetch_xml_as_text for tool calling
377+ * NOTE: Currently the logic is setup for the bundled simpleproxy.py
378+ * @param {Object<string, Object<string, any>> } tcs
379+ */
380+ async function fetchxmltext_setup ( tcs ) {
381+ return proxyserver_tc_setup ( 'FetchXmlAsText' , 'xmltext' , 'fetch_xml_as_text' , {
382+ "handler" : fetchxmltext_run ,
383+ "meta" : fetchxmltext_meta ,
384+ "result" : ""
385+ } , tcs ) ;
386+ }
387+
388+
389+ //
390+ // Entry point
391+ //
392+
332393
333394/**
334395 * Used to get hold of the web worker to use for running tool/function call related code
@@ -345,5 +406,6 @@ export async function init(me) {
345406 await fetchweburltext_setup ( tc_switch )
346407 await searchwebtext_setup ( tc_switch )
347408 await fetchpdftext_setup ( tc_switch )
409+ await fetchxmltext_setup ( tc_switch )
348410 return tc_switch
349411}
0 commit comments