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.
This commit is contained in:
hanishkvc 2025-11-05 19:29:45 +05:30
parent 0fcb13257c
commit d6fd4ea533
2 changed files with 16 additions and 14 deletions

View File

@ -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 * search_web_text - search for the specified words using the configured search engine and return the
plain textual content from the search result page. 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 * 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 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. * 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 #### ToDo

View File

@ -280,21 +280,21 @@ async function searchwebtext_setup(tcs) {
// //
// PdfText // FetchPdfText
// //
let pdftext_meta = { let fetchpdftext_meta = {
"type": "function", "type": "function",
"function": { "function": {
"name": "pdf_to_text", "name": "fetch_pdf_as_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", "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": { "parameters": {
"type": "object", "type": "object",
"properties": { "properties": {
"url":{ "url":{
"type":"string", "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":{ "startPageNumber":{
"type":"integer", "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 * Expects a simple minded proxy server to be running locally
* * listening on a configured port * * listening on a configured port
* * expecting http requests * * expecting http requests
@ -325,20 +325,20 @@ let pdftext_meta = {
* @param {string} toolname * @param {string} toolname
* @param {any} obj * @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'); 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 * NOTE: Currently the logic is setup for the bundled simpleproxy.py
* @param {Object<string, Object<string, any>>} tcs * @param {Object<string, Object<string, any>>} tcs
*/ */
async function pdftext_setup(tcs) { async function fetchpdftext_setup(tcs) {
return proxyserver_tc_setup('PdfText', 'pdftext', 'pdf_to_text', { return proxyserver_tc_setup('FetchPdfAsText', 'pdftext', 'fetch_pdf_as_text', {
"handler": pdftext_run, "handler": fetchpdftext_run,
"meta": pdftext_meta, "meta": fetchpdftext_meta,
"result": "" "result": ""
}, tcs); }, tcs);
} }
@ -359,6 +359,6 @@ export async function init(toolsWorker) {
await fetchweburlraw_setup(tc_switch) await fetchweburlraw_setup(tc_switch)
await fetchweburltext_setup(tc_switch) await fetchweburltext_setup(tc_switch)
await searchwebtext_setup(tc_switch) await searchwebtext_setup(tc_switch)
await pdftext_setup(tc_switch) await fetchpdftext_setup(tc_switch)
return tc_switch return tc_switch
} }