Commit Graph

337 Commits

Author SHA1 Message Date
hanishkvc 3e0cf2a2df SimpleChatTC:ObjPropsEdit: Obj within Obj aware fRefiner
Use same to set a placeholder for Authorization entry in headers
2025-12-04 19:41:39 +05:30
hanishkvc f874c69983 SimpleChatTC:UiShowObjPropsEdit allow refining 2025-12-04 19:41:39 +05:30
hanishkvc 6253c717b3 SimpleChatTC:Trappable UiShowObjPropsEdit for custom handling
Use it to handle apiEP and iRecentUserMsgCnt in more user friendly
way, where they get a selection to choose from.
2025-12-04 19:41:39 +05:30
hanishkvc 3718a39c06 SimpleChatTC:Use generic obj props edit for settings in general
Bring more user controllable properties into this new settings ui
2025-12-04 19:41:39 +05:30
hanishkvc 756b128539 SimpleChatTC:UI:ObjPropEdits handle objects, use for gMe 2025-12-04 19:41:39 +05:30
hanishkvc b771e42dc1 SimpleChatTC:UI:Common helper to edit obj members of few types
Make the previously relatively generic flow wrt apiRequestOptions
settings into a fully generic reusable by others flow.

Rather had stopped short of it, when previously moved onto other
things at that time.
2025-12-04 19:41:39 +05:30
hanishkvc 6e5b532313 SimpleChatTC:UI: el_get/el_set to avoid warnings 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 9b55775e8a SimpleChatTC:WebFetch: Update readme to reflect the new names 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 d04c8cd38d SimpleChatTC:SimpleProxy: Ensure CORS related headers sent always
Add a new send headers common helper and use the same wrt the
overridden send_error as well as do_OPTIONS

This ensures that if there is any error during proxy opertions,
the send_error propogates to the fetch from any browser properly
without browser intercepting it with a CORS error
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 73a144c44d SimpleChatTC:SimpleProxy:HtmlParser more generic and flexible
also now track header, footer and nav so that they arent captured
2025-12-04 19:41:39 +05:30
hanishkvc cd226e8dae SimpleChatTC: Update readme wrt web fetch and related simple proxy 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 9ff2c596ee SimpleChatTC:SimpleProxy:Options just in case 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 bf63b8f45a SimpleChatTC:SimpleProxy:UrlText: Slightly better trimming
First identify lines which have only whitespace and replace them
with lines with only newline char in them.

Next strip out adjacent lines, if they have only newlines
2025-12-04 19:41:39 +05:30
hanishkvc 266e825c68 SimpleChatTC:SimpleProxy:UrlText: Try strip empty lines some what 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 b46bbc542a SimpleChatTC:SimpleProxy:UrlText: Avoid style blocks also 2025-12-04 19:41:39 +05:30
hanishkvc f493e1af59 SimpleChatTC:SimpleProxy:UrlText: Capture body except for scripts 2025-12-04 19:41:39 +05:30
hanishkvc 45b05df21b SimpleChatTC:SimpleProxy: Switch to html.parser
As html can be malformed, xml ElementTree XMLParser cant handle
the same properly, so switch to the HtmlParser helper class that is
provided by python and try extend it.

Currently a minimal skeleton to just start it out, which captures
only the body contents.
2025-12-04 19:41:39 +05:30
hanishkvc d5f4183f7c SimpleChatTC:SimpleProxy: ElementTree, No _UrlopenRet
As _UrlopenRet not exposed for use outside urllib, so decode and
encode the data.

Add skeleton to try get the html/xml tree top elements
2025-12-04 19:41:39 +05:30
hanishkvc 6537559360 SimpleChatTC:SimpleProxy:Common UrlReq helper for UrlRaw & UrlText
Declare the result of UrlReq as a DataClass, so that one doesnt
goof up wrt updating and accessing members.

Duplicate UrlRaw into UrlText, need to add Text extracting from
html next for UrlText
2025-12-04 19:41:39 +05:30
hanishkvc e600e62e86 SimpleChatTC:SimpleProxy: Cleanup few messages 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 3bab4de0e8 SimpleChatTC:SimpleProxy:UrlRaw: Fixup basic oversight wrt 1st go 2025-12-04 19:41:39 +05:30
hanishkvc 73ef9f7d46 SimpleChatTC:SimpleProxy:implement handle_urlraw
A basic go at it
2025-12-04 19:41:39 +05:30
hanishkvc 73054a5832 SimpleChatTC:SimpleProxy: Extract and check path, route to handlers 2025-12-04 19:41:39 +05:30
hanishkvc c99788e290 SimpleChatTC:SimpleProxy: Cleanup for basic run 2025-12-04 19:41:39 +05:30
hanishkvc 80fd065993 SimpleChatTC:SimpleProxy: Start server, Show requested path 2025-12-04 19:41:39 +05:30
hanishkvc 05c0ade8be SimpleChatTC:SimpleProxy:Process args --port 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 09ce19a95a SimpleChatTC: update readme wrt promise related trapping 2025-12-04 19:41:39 +05:30
hanishkvc f0a3886d1e SimpleChatTC:Ensure fetch's promise chain is also trapped
Dont forget to map members of got entity from fetch to things
from saved original promise, bcas remember what is got is a promise.

also

add some comments around certain decisions and needed exploration
2025-12-04 19:41:39 +05:30
hanishkvc 77d3e43cb4 SimpleChatTC: Allow await in generated code that will be evald 2025-12-04 19:41:39 +05:30
hanishkvc 92e5b2133e SimpleChatTC:Promises: trap normal fetch (dont care await or not) 2025-12-04 19:41:39 +05:30
hanishkvc 0241b7b469 SimpleChatTC:TrapPromise: log the trapping
also possible refinement wrt trapping, if needed, added as comment

all or allSettled to use or not is the question.

whether to wait for a round trip through the related event loop or
not is also a question.
2025-12-04 19:41:39 +05:30
hanishkvc 3d661793ef SimpleChatTC:ChatMessageEx: 1st go at trying to track promises 2025-12-04 19:41:39 +05:30
hanishkvc 7dbbc46390 SimpleChatTC:ChatMessageEx: Better tool result extractor 2025-12-04 19:41:39 +05:30
hanishkvc 61b70bfa5d SimpleChatTC:Readme: Updated wrt new relativelyProper toolCallsHS
Also update the sliding window context size to last 9 chat messages
so that there is a sufficiently large context for multi turn tool
calls based adjusting by ai and user, without needing to go full
hog, which has the issue of overflowing the currently set context
window wrt the loaded ai model.
2025-12-04 19:41:39 +05:30
hanishkvc 152deb5d5a SimpleChatTC:ChatMessageEx:While at it also ns_delete
these common helpers avoid needing ignore tagging to ts-check, in
places where valid constructs have been used which go beyond strict
structured js handling that is tried to be achieved using it, but
are still valid and legal.
2025-12-04 19:41:39 +05:30
hanishkvc cc65a2f7a3 SimpleChatTC:ChatMessageEx: Build tool role result fully
Expand the xml format id, name and content in content field of
tool result into apropriate fields in the tool result message sent
to the genai/llm engine on the server.
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 2bb3d747e6 SimpleChatTC:ChatMessageEx: send tool_calls, only if needed 2025-12-04 19:41:39 +05:30
hanishkvc 2ef201ff8d SimpleChatTC:Load allows old and new ChatMessage(Ex) formats 2025-12-04 19:41:39 +05:30
hanishkvc 475858a4b3 SimpleChatTC:ChatMessageEx: Cleanup remaining stuff
wrt ChatMessageEx related required flow as well as avoid warnings
2025-12-04 19:41:39 +05:30
hanishkvc 963b9f4661 SimpleChatTC:ChatMessageEx: Recent chat users upd
Users of recent_chat updated to work with ChatMessageEx

As part of same recent_chat_ns also added, for the case where the
array of chat messages can be passed as is ie in the chat mode,
provided it has only the network handshake representation of the
messages.
2025-12-04 19:41:39 +05:30
hanishkvc 4d9e3d1566 SimpleChatTC:ChatMessageEx: Upd Add, rm sysPromptAtBeginOnly hlpr
Simplify Add semantic by expecting any validation of stuff before
adding to be done by the callers of Add and not by add itself.

Also update it to expect ChatMessageEx object

Update all users of add to follow the new syntax and semantic.

Remove the old and ununsed AddSysPromptOnlyAtBegin helper
2025-12-04 19:41:39 +05:30