Commit Graph

31 Commits

Author SHA1 Message Date
hanishkvc a4e023d21c SimpleChatTCRV:Config++:Cleanup the initial go
Ensure toolNames array is reset, each time setup is called, so
that it doesnt end up with duplicate entries and equally dont
end up with entries of tool calls which are no longer available,
maybe because some config changed etal.

Ensure the ChatId is logged wrt the toolweb related setup actions.

Ensure that ExternalAi tool call related chat session, has its
tools config disabled, when its created itself, so that end user
doesnt get confused, given that external_ai toolcall explicitly
forces tools support to disabled.

Update some of the notes and readme
2025-12-04 19:41:40 +05:30
hanishkvc 8e39afb05e SimpleChatTCRV:Config:Tools: Adapt for SimpleChat with Config
Split init from setup wrt Tools. Init is called when the program
is started, while setup is called when ever a session is created
and or when ever any tools setup related config is changed (like
proxyUrl getting modified or so).

This allows one to modify tool related config and inturn update
the tools related states wrt same (like wrt the proxyUrl, bcas
the simpleproxy server will change, one needs to cross check which
and all web services are available with the new simpleproxy server
and so and so ...)

To help with the above, now ToolsManager maintains multiple tool
call switches, where there will be a tc_switch wrt each chat
session.

All tool related codes, where needed have been updated to work
with the chat session for which they have been called, instead
of any global states.

In future, this can enable one to allow user to enable or disable
the tool calls exposed in each of the chat sessions,

This immidiately needed toolweb and toolai to account for chat
session as needed.

In future, if we want to keep the data store isolated across
chat sessions, then this can be useful, in that it can create
uniq store names for each of the chat sessions, isntead of
sharing a common store name across all sessions.

The chat session creation as well as tool init/setup related
flows have been updated to chain through or account for the
promises as needed
2025-12-04 19:41:40 +05:30
hanishkvc 68e4285288 SimpleChatTCRV:Config:WIP:Switch SimpleChat to Config from Me
Update SimpleChat to have a duplicated instance of Config instead
of a reference to the global Me instance.

Most logics updated to work with the config entries corresponding
to the current chat session.

ShowSettings, ShowInfo and getting current sliding window size in
user friendly textual form have been moved to Config from Me.

ALERT: With this now, user clicking settings will be able to modify
only the settings corresponding to current in focus chat session.

TODO:
ToolsMgr related use within SimpleChat and beyond needs to be thought
through and updated as needed.

Should tools.proxyUrl be unique to each SimpleChat or ...
2025-12-04 19:41:40 +05:30
hanishkvc 143f9c0b1a SimpleChatTC:Rename fetch_web_url_text to fetch_html_text
To make it easier for the ai model to understand that this works
mainly for html pages and not say xml or pdf or so. For those
one needs to use other explict tool calls provided like fetchpdftext
or fetchxmltext or so

The server service path renamed from urltext to htmltext.

SearchWebText also updated to use htmltext now
2025-12-04 19:41:39 +05:30
hanishkvc 9f5c3d7776 SimpleChatTC:XmlFiltered: Use re with heirarchy of tags to filter
Rename xmltext to xmlfiltered.

This simplifies the filtering related logic as well as gives more
fine grained flexibility wrt filtering bcas of re.
2025-12-04 19:41:39 +05:30
hanishkvc 9ed1cf9886 SimpleChatTC:XMLFiltered: Retain xml tags with selective dropping
instead of the prefixing of tag heirarchy retain the xml structure
while parallely allowing unwanted tags and their contents to be
dropped.
2025-12-04 19:41:39 +05:30
hanishkvc b8bb258dd5 SimpleChatTC:XmlText: Cleanup initial go
At simpleproxy end

* Add the tag names hierarchy before contents of a tag

* Remember to convert the tagDrops to small case as HTMLParser base
  class seems to do that by default.

At the client ui end

* if undefined remember to pass a empty list wrt tagDrops.

* cleanup the func description and also mention possible tagDrops
  for RSS feeds in the tool meta
2025-12-04 19:41:39 +05:30
hanishkvc fbe9b2369f SimpleChatTC:XmlText: Add plumbing on web client ui ie js side
Add the meta data for the fetch xml as text tool call

Implement the handler and the setup tool call plumbing logic
2025-12-04 19:41:39 +05:30
hanishkvc 4d71ded5df SimpleChatTC:ToolsManager: Instantiate in Me and Use
Rename Tools to ToolsManager to convey its semantic better.

Move setup of workers onmessage callback as well as directly passing
result to these callbacks into ToolsManager.

Now that Workers have been moved into ToolsManager, and ToolsManager
has been instantiated as a member of Me, use the same in place of
prev workers of Me.
2025-12-04 19:41:39 +05:30
hanishkvc 0e7fe8bcf2 SimpleChatTC:MeInTools: WebWorkers in Me
Given that Me is now passed to the tools logic during setup, have
the web worker handles in Me itself, instead of in tool related
modules.

Move setup of web worker related main thread callbacks, as well as
posting messages directly to these main thread callbacks, into Me.
2025-12-04 19:41:39 +05:30
hanishkvc 85c2779579 SimpleChatTC:Cleanup:MeInTools: update tools, toolweb
Now gMe can be used in toolweb with proper knowledge of available
members and can also be cross checked by tools
2025-12-04 19:41:39 +05:30
hanishkvc d6fd4ea533 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.
2025-12-04 19:41:39 +05:30
hanishkvc c316f5a2bd SimpleChatTC:WebTools:UrlText:HtmlParser: tag drops - refine
Update the initial skeleton wrt the tag drops logic

* had forgotten to convert object to json string at the client end
* had confused between js and python and tried accessing the dict
  elements using . notation rather than [] notation in python.
* if the id filtered tag to be dropped is found, from then on
  track all other tags of the same type (independent of id),
  so that start and end tags can be matched. bcas end tag call
  wont have attribute, so all other tags of same type need to
  be tracked, for proper winding and unwinding to try find
  matching end tag
* remember to reset the tracked drop tag type to None once matching
  end tag at same depth is found. should avoid some unnecessary
  unwinding.
* set/fix the type wrt tagDrops explicitly to needed depth and
  ensure the dummy one and any explicitly got one is of right type.

Tested with duckduckgo search engine and now the div based unneeded
header is avoided in returned search result.
2025-12-04 19:41:39 +05:30
hanishkvc 06fd41a88e SimpleChatTC:WebTools: urltext-tag-drops python side - skel
Rename search-drops to urltext-tag-drops, to indicate its more
generic semantic. Rather search drops specified in UI by user
will be mapped to urltext-tag-drops header entry of a urltext
web fetch request.

Implement a crude urltext-tag-drops logic in TextHtmlParser.
If there is any mismatch with opening and closing tags in the
html being parsed and inturn wrt the type of tag being targetted
for dropping, things can mess up.
2025-12-04 19:41:39 +05:30
hanishkvc f75bdb0e00 SimpleChatTC:WebTools And Search - headers and search drops - js
Allow the web tools handshake helper to pass additional header
entries provided by its caller.

Make use of this to send a list of tag and id pairs wrt web search
tool. Which will be used to drop div's matching the specified id.
2025-12-04 19:41:39 +05:30
hanishkvc 1d1894ad14 SimpleChatTC:PdfText:Cleanup rename to follow a common convention
Rename path and tags/identifiers from Pdf2Text to PdfText

Rename the function call to pdf_to_text, this should also help
indicate semantic more unambiguously, just in case, especially
for smaller models.
2025-12-04 19:41:39 +05:30
hanishkvc dd0a7ec500 SimpleChatTC:Pdf2Text: Make it work with a subset of pages
Initial go, need to review the code flow as well as test it out
2025-12-04 19:41:39 +05:30
hanishkvc 63a8ddfbb9 SimpleChatTC:SimpleProxyHS: make helper work with any num of args
This makes the logic more generic, as well as prepares for additional
parameters to be passed to the simpleproxy.py helper handshakes.

Ex: Restrict extracted contents of a pdf to specified start and end
page numbers or so.
2025-12-04 19:41:39 +05:30
hanishkvc 61064baa19 SimpleChatTC:Pdf2Text and otherwise readme update
Half asleep as usual ;)
2025-12-04 19:41:39 +05:30
hanishkvc e077f23f9e SimpleChatTC:Pdf2Text: Refine desc and MaxResultDataLength
Needed to tweak the description further for the ai model to be
able to understand that its ok to pass file:// scheme based urls

Had forgotten how big the web site pages have become as also the
need for more ResultDataLength wrt one shot PDF read to get
atleast some good enough amount of content in it with large pdfs
2025-12-04 19:41:39 +05:30
hanishkvc 21544eaf87 SimpleChatTC:ResultMaxDataLength, Desc
Allow user to limit the max amount of result data returned to ai
after a tool call.

Inturn it is set by default to 2K.

Update the pdf2text tool description to try make the local file
path support more explicit
2025-12-04 19:41:39 +05:30
hanishkvc dfeb94d3f6 SimpleChatTC:Pdf2Text: cleanup initial go
Make the description bit more explicit with it supporting local
file paths as part of the url scheme, as the tested ai model was
cribbing about not supporting file url scheme. Need to check if
this new description will make things better.

Convert the text to bytes for writing to the http pipe.

Ensure CORS is kept happy by passing AccessControlAllowOrigin in
header.
2025-12-04 19:41:39 +05:30
hanishkvc f97efb86e4 SimpleChatTC:SimpleProxy:Pdf2Text: js side initial plumbing
Expose pdf2text tool call to ai server and handshake with simple
proxy for the same.
2025-12-04 19:41:39 +05:30
hanishkvc 25df32b553 SimpleChatTC:ChatSessionID: Get all handlers to account for chatid
This should ensure that tool call responses can be mapped back to
the chat session for which it was triggered.
2025-12-04 19:41:39 +05:30
hanishkvc 84403973cd SimpleChatTC:SimpleProxy: once in a bluemoon transformed bearer
instead of using the shared bearer token as is, hash it with
current year and use the hash.

keep /aum path out of auth check.

in future bearer token could be transformed more often, as well as
with additional nounce/dynamic token from server got during initial
/aum handshake as also running counter and so ...

NOTE: All these circus not good enough, given that currently the
simpleproxy.py handshakes work over http. However these skeletons
put in place, for future, if needed.

TODO: There is a once in a bluemoon race when the year transitions
between client generating the request and server handling the req.
But other wise year transitions dont matter bcas client always
creates fresh token, and server checks for year change to genrate
fresh token if required.
2025-12-04 19:41:39 +05:30
hanishkvc 0552ff9098 SimpleChatTC:SimpleProxy:ClientUI: Send Authorization bearer
User can configure the bearer token to send
2025-12-04 19:41:39 +05:30
hanishkvc 044d1cf535 SimpleChatTC:tools.proxyUrl: rename to just proxyUrl
Next will be adding a proxyAuth field also to tools.
2025-12-04 19:41:39 +05:30
hanishkvc 221b5a9228 SimpleChatTC:ToolCallWeby: Cleanup the toolweb module flow
Avoid code duplication, by creating helpers for setup and toolcall.

Also send indication of the path that will be used, when checking
for simpleproxy.py server to be running at runtime setup.
2025-12-04 19:41:39 +05:30
hanishkvc de6f370d3b SimpleChatTC:ToolCall:SearchWebText using UrlText
Initial go at implementing a web search tool call, which uses the
existing UrlText support of the bundled simpleproxy.py.

It allows user to control the search engine to use, by allowing
them to set the search engine url template.

The logic comes with search engine url template strings for
duckduckgo, brave, bing and google. With duckduckgo set by default.
2025-12-04 19:41:39 +05:30
hanishkvc 978ee3db1e SimpleChatTC:ToolCalling:Seprat out JSWebWorker and ProxyBasedWeb
Remove the unneed (belonging to the other file) stuff from tooljs
and toolweb files.

Update tools manager to make use of the new toolweb module
2025-12-04 19:41:39 +05:30
hanishkvc d00e5b341a SimpleChatTC:Duplicate tooljs.mjs to toolweb.mjs
So as to split browser js webworker based tool calls from web
related tool calls.
2025-12-04 19:41:39 +05:30