Commit Graph

36 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 631d9ceec5 SimpleChatTCRV:ToolCalls Cleanup
Update the external ai tool call description to indicate that it
doesnt have access to internet or tool calls.

Update the sys_date_time description and avoid the confusion caused
to some ai wrt the template string as to whether it is optional or
required and wasting reasoning time around it. Now simply state that
it is a reqd argument, and suggest the internal default template as
a useful one to use.

Update the msg returned by data store tool calls, to make them less
verbose (ie avoid duplicating key list or got key data) while also
more informative (ie num of keys, data length)

Update the readme.
2025-12-04 19:41:40 +05:30
hanishkvc 087fd93495 SimpleChatTCRV:SysDateTime: Follow unix date format markers
Also support w ie day of week.
2025-12-04 19:41:40 +05:30
hanishkvc 735a8b382c SimpleChatTCRV:Cleanup: Starting flow, cleanup description, readme
Avoid chat_show getting called twice during starting.

Update description of sys_date_time to be more verbose

Update the readme DONE section, where I had few days back forgotten
and started making entries as parts of a item list or so.
2025-12-04 19:41:40 +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 83a4b1a3fa SimpleChatTC:System Date and Time 2025-12-04 19:41:39 +05:30
hanishkvc 2f58542713 SimpleChatTC:DataStore: Duplicate tooljs to tooldb initial skel 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 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 f74ce327e5 SimpleChatTC: Cleanup whitespaces
identified by llama.cpp editorconfig check

* convert tab to spaces in json config file
* remove extra space at end of line
2025-12-04 19:41:39 +05:30
hanishkvc 3e490cefc5 SimpleChatTC:Cleanup: Move bTools and toolFetchProxyUrl into tools
Also update the readme wrt same and related
2025-12-04 19:41:39 +05:30
hanishkvc 2a94cb3786 SimpleChatTC:Fetch:Proxy URL rename and in settings 2025-12-04 19:41:39 +05:30
hanishkvc 98d43fac7f SimpleChatTC:WebFetch: Try confirm simpleproxy before enabling 2025-12-04 19:41:39 +05:30
hanishkvc a6aa563a18 SimpleChatTC:WebFetch: Check for the specific proxy paths 2025-12-04 19:41:39 +05:30
hanishkvc 80dbbb89a5 SimpleChatTC:WebFetch: Enable only if something at proxyUrl
NOTE: not a robust check, just tries to establish a http connection
for now and doesnt really check if it is the specific proxy srvr
of interest or not.
2025-12-04 19:41:39 +05:30
hanishkvc 04644761e6 SimpleChatTC:Tools: Pick proxy server address from document[gMe] 2025-12-04 19:41:39 +05:30
hanishkvc 42f91df261 SimpleChatTC:WebFetch:Trap Non Ok status and raise error
So that the same error path is used for logical error wrt http req
also, without needing a different path for it.

Dont forget to return the resp text/json/..., so that the contents
are passed along the promise then chain
2025-12-04 19:41:39 +05:30
hanishkvc c2fb0cd241 SimpleChatTC:WebFetch: Cleanup the names and descriptions a bit 2025-12-04 19:41:39 +05:30
hanishkvc 8b950fd348 SimpleChatTC:WebFetch:UrlEnc url2fetch b4Passing toProxy asQuery
Ensures that if the url being requested as any query strings in
them then things dont get messed up, when the url to get inc its
query is extracted from the proxy request's query string
2025-12-04 19:41:39 +05:30
hanishkvc 9c7d6cc0e4 SimpleChatTC:WebUrlText:Update name and desc to see if prefered 2025-12-04 19:41:39 +05:30
hanishkvc 82ab08ec1a SimpleChatTC:WebUrl FetchStrip through simple proxy 2025-12-04 19:41:39 +05:30
hanishkvc c25b1968cd SimpleChatTC:WebFetch: Update to use internal SimpleProxy.py 2025-12-04 19:41:39 +05:30
hanishkvc 8fc74ef923 SimpleChatTC:WebFetchThroughProxy:Initial go creating request 2025-12-04 19:41:39 +05:30
hanishkvc ebc7f88b53 SimpleChatTC:Propogate toolcall id through tool call chain
Use HTMLElement's dataset to maintain tool call id along with
the element which maintains the toolname.

Pass it along to the tools manager and inturn the actual tool
calls and through them to the web worker handling the tool call
related code and inturn returning it back as part of the obj
which is used to return the tool call result.

Embed the tool call id, function name and function result into
the content field of chat message in terms of a xml structure

Also make use of tool role to send back the tool call result.
Do note that currently the id, name and content are all embedded
into the content field of the tool role message sent to the
ai engine on the server.

NOTE: Use the user query entry area for showing tool call result
in the above mentioned xml form, as well as for user to enter
their own queries. Based on presence of the xml format data at
beginning the logic will treat it has a tool result and if not
then as a normal user query.

The css has been updated to help show tool results/msgs in a
lightyellow background
2025-12-04 19:41:39 +05:30
hanishkvc 37faf8611a SimpleChatTC: update descs to indicate use of web workers
ie wrt the tool calls provided.
2025-12-04 19:41:39 +05:30
hanishkvc 2a8bd1c9e7 SimpleChatTC: Actual tool call implementations simplified
These no longer need to worry about

* setting up the console.log related redirection to capture
  the generated outputs, nor about
* setting up a dynamic function for executing the needed
  tool call related code

The web worker setup to help run tool calls in a relatively
isolated environment independent of the main browser env,
takes care of these.

One needs to only worry about getting the handle to the
web worker to use and inturn pass the need code wrt the
tool call to it.
2025-12-04 19:41:39 +05:30
hanishkvc 2701cb3a1e SimpleChatTC: Move console.log trapping into its own module
So that it can be used from different modules, if required.
2025-12-04 19:41:39 +05:30
hanishkvc 63b5c6d76d SimpleChatTC: Cleanup the function description a bit
to better describe how it will be run, so that genai/llm while
creating the code to run, will hopefully take care of any naunces
required.
2025-12-04 19:41:38 +05:30
hanishkvc a80da9a652 SimpleChatTC: Pass toolname to the tool handler
So that when tool handler writes the result to the tc_switch, it
can make use of the same, to write to the right location.

NOTE: This also fixes the issue with I forgetting to rename the
key in js_run wrt writing of result.
2025-12-04 19:41:38 +05:30
hanishkvc a408e5e017 SimpleChatTC: More clearer description of toolcalls execution env
Should hopeful ensure that the GenAi/LLM will generate appropriate
code/expression as the argument to pass to these tool calls, to
some extent.
2025-12-04 19:41:38 +05:30
hanishkvc 17c5daa52c SimpleChatTC: Cleanup initial/1st go toolcall flow
As output generated by any tool/function call is currently placed
into the TextArea provided for End user (for their queries), bcas
the GenAi (engine/LLM) may be expecting the tool response to be
sent as a user role data with tool_response tag surrounding the
results from the tool call. So also now at the end of submit btn
click handling, the end user input text area is not cleared, if
there was a tool call handled, for above reasons.

Also given that running a simple arithmatic expression in itself
doesnt generate any output, so wrap them in a console.log, to
help capture the result using the console.log trapping flow that
is already setup.
2025-12-04 19:41:38 +05:30
hanishkvc fa63a86c71 SimpleChatTC:tooljs: Trap console.log and store in new result key
The implementations of javascript and simple_calculator now use
provided helpers to trap console.log messages when they execute
the code / expression provided by GenAi and inturn store the
captured log messages in the newly added result key in tc_switch

This should help trap the output generated by the provided code
or expression as the case maybe and inturn return the same to the
GenAi, for its further processing.
2025-12-04 19:41:38 +05:30
hanishkvc 46f0304105 SimpleChatTC: More generic tooljs, SimpCalc, some main skeleton
Make tooljs structure and flow more generic

Add a simple_calculator tool/function call logic

Add initial skeleton wrt the main tools.mjs file.
2025-12-04 19:41:38 +05:30
hanishkvc f1aa0ee778 SimpleChatTC: Add skeleton for a javascript interpretor tool call
Define the meta that needs to be passed to the GenAi Engine.

Define the logic that implements the tool call, if called.

Implement the flow/structure such that a single tool calls
implementation file can define multiple tool calls.
2025-12-04 19:41:38 +05:30