Implement todo noted in last commit, and bit more.
This brings in clearing of the external ai tool call special chat
session divStream during chat show, which ensures that it gets
hidden by default wrt other chat sessions and inturn only get
enabled if user triggers a new tool call involving external ai
tool call.
This patch also ensures that if ext ai tool call takes too much
time and so logic gives you back control with a timed out response
as a possible response back to ai wrt the tool call, then the
external ai tool call's ai live response is no longer visible in
the current chat session ui. So user can go ahead with the timed
out response or some other user decided response as the response
to the tool call. And take the chat in a different direction of
their and ai's choosing.
Or else, if they want to they can switch to the External Ai
specific special chat session and continue to monitor the response
from the tool call there, to understand what the final response
would have been wrt that tool call.
Rather this should keep the ui flow clean.
ALERT: If the user triggers a new ext ai tool call, when the
old one is still alive in the background, then response from
both will be in a race for user visibility, so beware of it.
Always show all the info wihen show_info is called, inturn avoid
the corresponding all info enable flag wrt show_info as well as
chat_show.
Now chat_show gives the option to its caller to enable showing of
its own chat session divStream. This is in addition to the handle
multipart response also calling corresponding divStream show.
Previously chat_show would have not only cleared corresponding chat
session's divStream contents but would have also hidden divStream.
Now except for the clearChat case, in all other cases own divStream
is unhidden, when chat_show is called.
Without this, when a tool call takes too much time and inturn
a chat session times out the tool call and inturn user switches
between chat sessions, if the tool call was external_ai, then its
related live ai response would no longer be visible in any of the
chat sessions, including the external_ai special chat session, if
the user had switched to this external_ai special chat session.
But now in the external_ai special chat session, the live response
will be visible.
TODO: With this new semantic wrt chat_show, where a end user can
always peek into a chat session's ai live stream response if any,
as long as that chat session's ai server handshake is still active,
So now After tool call timeout, which allows users to switch between
sessions, it is better to disable the external ai live divStream
in other chat sessions, when user switches into them. This ensures
that
1. if user doesnt switch out of the chat session which triggered
external_ai, for now the user can continue to see the ext ai live
response stream.
2. Switching out of the chat session which triggered ext ai, will
automatically disable viewing of external ai live response from
all chat sessions except for the external ai's special chat session.
IE I need to explicitly clear not just the own divStream, but also
the external ai related divStream, which is appened to end of all
chat session's UI.
This will tidy up the usage flow and ui and avoid forcefully showing
external ai tool call's ai live response in other chat sessions,
which didnt trigger the ext ai tool call. And also in the chat
session which triggered ext ai, it will stop showing if user exits
out of that chat session. Same time user can always look at the
ext ai live response stream in the special chat session corresponding
to ext ai.
If user explicitly makes a content text format selection, the
same will be used.
Else based on session settings, a format will be used.
Now when the popover menu is shown, the current message's format
type is reflected in the popover menu.
Add format selection box to the popover.
Update show_message logic to allow refreshing a existing message
ui element, rather than creating a new one.
Trigger refresh of the message ui element, when format selection
changes.
Move all markdown configs into a single object field.
Add always flag, which if set, all roles' message contents will be
treated as markdown, else only ai assistant's messages will be
treated as markdown.
If lines immidately follows a list item, without the list marker
at their begining, but with a offset matching the list item, then
these lines will be appended to that list item.
If a empty line is there between a list item and a new line with
some content, but without a list marker
* if the content offset is less than the last list item, then
unwind the lists before such a line.
* if the content offset is larger than the last list item, then
the line will be added as a new list item at the same level
as the last list item.
* if the content offset is same as the last list tiem, then
unwind the list by one level and then insert this line as a
new list item at this new unwound level.
Given that now fetch_web_url_raw can also fetch local files, if local
file access scheme is enabled in simpleproxy.py, so rename this
tool call by dropping web from its name, given that some ai models
were getting confused because of the same.
Maintain raw and sanitized versions of line.
Make blockquote work with raw line and not the sanitized line.
So irrespective of whether sanitize is enabled or not, the logic
will still work. Inturn re-enable HtmlSanitize.
Similar to listitem before, now also allow a para to have its long
lines split into adjacent lines. Inturn the logic will take care of
merging them into single para.
The common logic wrt both flows moved into its own helper function.
If the split lines dont have any empty lines inbetween and also
remain within the block area of the list item which they belong
to, then the split line will be appended to the corresponding
list item, ELSE a new list item will be created.
To help with same a generic keyed empty lines tracker logic has
been added.
TODO: Account similar semantic wrt paragraph related split lines
If a split line is found which remains within the constraints of
the preceding list item, then dont unwind the list, rather for
now add the split line as a new item at the same level.
Start ordered or unordered list as the case may be and push the
same into endType for matching unwinding.
Ignore empty lines and dont force a list unwind.
Avoid seperate new list level logic for a fresh list and list with
in list paths. Rather adjust lastOffset specifically for fresh list.
All paths lead to need to insert list item and the difference to be
handled wrt starting or ending a list level is handled by respective
condition check blocks directly without delaying it for later so no
need for that sList state, so remove.
Avoid check for same level list item path, as nothing special needs
to be do in that path currently.
Live identify the last offset, when unwinding.
NOTE: Logic currently will handle ordered lists on their own or
unordered lists on thier own or intermixed list containing both
type of lists within them, however remember that all will be shown
as unordered lists.
ALERT: if there is a really long line, the logic currently doesnt
support it being broken into smaller line with same or greater
offset than the line identifying the current list item.
Save copy of data being processed.
Try and sanitize the data passed for markdown to html conversion,
so that if there are any special characters wrt html in the passed
markdown content, it gets translated into a harmless text.
This also ensures that those text dont disappear, bcas of browser
trying to interpret them as html tagged content.
Trap any errors during sanitizing and or processing of the lines
in general and push them into a errors array. Callers of this
markdown class can decide whether to use the converted html or
not based on errors being empty or not or ...
Move the processing of unordered list into a function of its own.
Rather the ordered list can also use the same flow in general except
for some tiny changes including wrt the regex, potentially.
User can enable or disable the simple minded bruteforce markdown
parsing from the per session settings.
Add grey shading and align text to left wrt table headings of
markdown to html converted tables.
Switch to the simpler split based flow.
Include tr wrt the table head block also.
Add a css entry to try and have header cell contents text aling
to left for now, given that there is no border or color shaded
or so distinguishing characteristics wrt the table cells for now.
Rather this wont work, need to refresh on regex, been too long.
Rather using split should be simpler
However the extraction of head and body parts with seperation
inbetween for transition should work
Rather the seperation is blindly assumed and corresponding line
discarded for now
Allow fenced code block / pre to be demarkated using either ```
or ~~~
Ensure the termination line wrt fenced block doesnt contain anything
else.
Same starting marker needs to be present wrt ending also
Ensure '---' is treated as a horizontal line and doesnt mess with
unordered list handling.
Take care of unwinding the unordered list everywhere it is needed.
Remove markdown heading markers
Fix pre equivalent blocks of markdown given that they can have
the block type following ``` marker
Remember to add line break at end of line wrt pre block.
By default ensure external_ai tool call related special chat session
starts with tool calls disabled and client side sliding window of 1.
Add a helper in SimpleChat class to set these along with clearing of
any chat history.
Inturn now give the user flexibility to change this from within
the program, if they need to for what ever reason, till the program
restarts.
Gives quick overview of the features, given that the original readme
(now docs/details.md++) got created over a period of disjoined time
as features got added.
Ensure we are working with the Chat Messages in Chat session, which
are in the currently active sliding window.
Remove any chat message blocks in the chat session ui, which are
no longer in the sliding window of context.
This brings uirefresh semantic to be in sync with chat_show logic