From d6fd4ea5337e849aa437ab99be425752976c570e Mon Sep 17 00:00:00 2001 From: hanishkvc Date: Wed, 5 Nov 2025 19:29:45 +0530 Subject: [PATCH] SimpleChatTC:FetchPdfAsText: Renamed function call Some ai's dont seem to be prefering to use this direct helper provided for fetching pdf as text, on its own. Instead ai (gptoss) seems to be keen on fetching raw pdf and extract text etal, so now renaming the function call to try and make its semantic more readily obivious hopefully. It sometimes (not always) seem to assum fetch_web_url_text, can convert pdf to text and return it. Maybe I need to place the specific fetch pdf as text before the generic fetch web url text and so... With the rename, the pdf specific fetch seems to be getting used more. --- tools/server/public_simplechat/readme.md | 4 +++- tools/server/public_simplechat/toolweb.mjs | 26 +++++++++++----------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/tools/server/public_simplechat/readme.md b/tools/server/public_simplechat/readme.md index 44437e0d10..27696c04bf 100644 --- a/tools/server/public_simplechat/readme.md +++ b/tools/server/public_simplechat/readme.md @@ -458,7 +458,7 @@ Either way always remember to cross check the tool requests and generated respon * search_web_text - search for the specified words using the configured search engine and return the plain textual content from the search result page. -* pdf_to_text - fetch/read specified pdf file and extract its textual content +* fetch_pdf_as_text - fetch/read specified pdf file and extract its textual content * this depends on the pypdf python based open source library the above set of web related tool calls work by handshaking with a bundled simple local web proxy @@ -626,6 +626,8 @@ sliding window based drop off or even before they kick in, this can help in many * UI - add ClearChat button and logic. Also add unicode icons for same as well as for Settings. +* renamed pdf_to_text to fetch_pdf_as_text so that ai model can understand the semantic better. + #### ToDo diff --git a/tools/server/public_simplechat/toolweb.mjs b/tools/server/public_simplechat/toolweb.mjs index d4c2788340..0163d880a6 100644 --- a/tools/server/public_simplechat/toolweb.mjs +++ b/tools/server/public_simplechat/toolweb.mjs @@ -280,21 +280,21 @@ async function searchwebtext_setup(tcs) { // -// PdfText +// FetchPdfText // -let pdftext_meta = { +let fetchpdftext_meta = { "type": "function", "function": { - "name": "pdf_to_text", - "description": "Read pdf from requested local file path / web url through a proxy server and return its text content after converting pdf to text, in few seconds. One is allowed to get a part of the pdf by specifying the starting and ending page numbers", + "name": "fetch_pdf_as_text", + "description": "Fetch pdf from requested local file path / web url through a proxy server and return its text content after converting pdf to text, in few seconds. One is allowed to get a part of the pdf by specifying the starting and ending page numbers", "parameters": { "type": "object", "properties": { "url":{ "type":"string", - "description":"local file path (file://) / web (http/https) based url of the pdf that will be got and inturn converted to text to an extent" + "description":"local file path (file://) / web (http/https) based url of the pdf that will be got and inturn converted to text" }, "startPageNumber":{ "type":"integer", @@ -312,7 +312,7 @@ let pdftext_meta = { /** - * Implementation of the pdf to text logic. + * Implementation of the fetch pdf as text logic. * Expects a simple minded proxy server to be running locally * * listening on a configured port * * expecting http requests @@ -325,20 +325,20 @@ let pdftext_meta = { * @param {string} toolname * @param {any} obj */ -function pdftext_run(chatid, toolcallid, toolname, obj) { +function fetchpdftext_run(chatid, toolcallid, toolname, obj) { return proxyserver_get_anyargs(chatid, toolcallid, toolname, obj, 'pdftext'); } /** - * Setup pdftext for tool calling + * Setup fetchpdftext for tool calling * NOTE: Currently the logic is setup for the bundled simpleproxy.py * @param {Object>} tcs */ -async function pdftext_setup(tcs) { - return proxyserver_tc_setup('PdfText', 'pdftext', 'pdf_to_text', { - "handler": pdftext_run, - "meta": pdftext_meta, +async function fetchpdftext_setup(tcs) { + return proxyserver_tc_setup('FetchPdfAsText', 'pdftext', 'fetch_pdf_as_text', { + "handler": fetchpdftext_run, + "meta": fetchpdftext_meta, "result": "" }, tcs); } @@ -359,6 +359,6 @@ export async function init(toolsWorker) { await fetchweburlraw_setup(tc_switch) await fetchweburltext_setup(tc_switch) await searchwebtext_setup(tc_switch) - await pdftext_setup(tc_switch) + await fetchpdftext_setup(tc_switch) return tc_switch }