Commit graph

2977 commits

Author SHA1 Message Date
HanishKVC
c2e8d62707 SimpleChat:MCUI:CornerCases:Skip new chat, show only if current
Skip NewChat if user cancels or if one waiting for response from
the ai model.

Dont show a chat with newly got ai model response, if current chat
session has changed, some how. Chat session shouldnt be allowed to
change, if there is a pending response, but still as a additional
sanity check.
2024-05-21 22:31:57 +05:30
HanishKVC
d3405ea072 SimpleChat:MCUI: NewChat btn first before existing chat sessions 2024-05-21 21:07:34 +05:30
HanishKVC
6c71277513 SimpleChat:MCUI: CreateSessionBtn helper, use wrt NewChat
Also fix a oversight wrt using stale data wrt the list of chat
sessions.
2024-05-21 20:55:09 +05:30
HanishKVC
14083d157f SimpleChat:MCUI: Support for new chat sessions
Also a general create button helper.
2024-05-21 20:18:07 +05:30
HanishKVC
2a407192fc SimpleChat:MCUI: Ensure req-resp failure doesnt lock up things 2024-05-21 19:04:32 +05:30
HanishKVC
68ef7401ed SimpleChat:Cleanup corners
Show system prompt in chat space, when it is set by pressing enter,
as a feedback to user.

Alert user, if they try to switch chat session in the middle of
waiting for a response from the ai model.
2024-05-21 18:33:27 +05:30
HanishKVC
b9f9c0ec6e SimpleChat:MCUI: Allow selected chat-session btn to be highlighted
Also have a general helper for setting class of children.
2024-05-21 18:09:35 +05:30
HanishKVC
3458d2f8c3 SimpleChat:GetSystemLatest, fix a oversight. 2024-05-21 17:39:49 +05:30
HanishKVC
7297dda376 SimpleChat: Take care of system prompt
Helper to get the latest system prompt and inturn use same to
set the system prompt ui, when switching.

Ensure that system prompt is set if and when enter key is pressed.
2024-05-21 17:24:06 +05:30
HanishKVC
d57274b2a3 SimpleChat:MCUI: Delay enabling user-input to avoid race
Re-enable user-input, only after response to a user query has been
updated to the chat-div. This ensures that if user tries to switch
chat session, it wont be allowed till chat-request-response flow is
done.
2024-05-21 16:48:32 +05:30
HanishKVC
928cc36427 SimpleChat:MCUI: Store and use current chat session id
Also

allow to switch chat session optionally, wrt some of the related
helpers.

setup for two chat sessions by default.
2024-05-21 16:44:21 +05:30
HanishKVC
1b82f2281f SimpleChat:MCUI:Show available chat sessions, try switch btw them
Previous commits brought in / consolidated existing logic into
MultiChatUI class.

Now start adding logic towards multichat support

* show buttons indicating available chat sessions

* on sessin button click, try switch to that session
2024-05-21 15:47:14 +05:30
HanishKVC
1cd10ae9c4 SimpleChat: Move ui elements into MultiChatUI, Update el IDs
Move ui elements into MultiChatUI, so that current handleUserSubmit
doesnt need to take the element arguments. Also in future, when
user is allowed to switch between different chat sessions, the
UI can be updated as needed by using the elements in UI already
known to MultiChatUI instance.

Rename the element ids' so that they follow a common convention,
as well as one can identify what the element represents in a more
consistant manner.
2024-05-21 14:31:24 +05:30
HanishKVC
7be6aeb6d6 SimpleChat:JS: Move to dictionary of SimpleChat, instead of array 2024-05-21 00:18:58 +05:30
HanishKVC
8ef1aa97a6 SimpleChat:JS: Move handle submit into MultiChat, build on same
Create an instance of MultiChatUI and inturn a instance of chat
session, which is what the UI will inturn work on.
2024-05-20 23:43:51 +05:30
HanishKVC
fcf2af9504 SimpleChat:JS:Keep MultiChatUI simple for now
Worry about different chats with different servers for later.
2024-05-20 23:21:26 +05:30
HanishKVC
5c1a9f4d8b SimpleChat:JS: Move system prompt begin/anytime into SimpleChat 2024-05-20 22:59:32 +05:30
HanishKVC
9b97feab45 SimpleChat:JS: MultiChat initial skeleton
Will help maintain multiple independent chats in future
2024-05-20 22:38:36 +05:30
HanishKVC
af621975bb SimpleChat:JS:CI: Avoid space at end of jsdoc param line 2024-05-20 21:34:48 +05:30
HanishKVC
3fc607f832 SimpleChat: Screen fixed view and scrolling, Printing full 2024-05-20 21:27:39 +05:30
HanishKVC
e5000cdb83 SimpleChat: Rename simplechat.html to index.html, update readme
Instead of providing a seperate shell script, update the readme wrt
how to run/use this web front end.
2024-05-20 18:18:23 +05:30
HanishKVC
6597fafeae SimpleChat: Make vertical layout better responsive (flex based)
Also needed to make things cleaner and properly usable whether
landscape or portrait, after changing to multiline textarea rather
than single line user input.

Avoid hardcoding the chat-till-now display area height, instead
make it a flex-growable within a flex column of ui elements within
a fixed vertical area.
2024-05-20 16:31:13 +05:30
HanishKVC
dfadac7813 SimpleChat: textarea for multiline user chat, inturn shift+enter 4 enter 2024-05-20 11:59:07 +05:30
HanishKVC
c88088c7a1 SimpleChat:HtmlCss: Cleanup UI flow
set margin wrt vmin rather than vw or vh so portrait/landscape ok.

Use flex and flex-grow to put things on the same line as well as
distribute available space as needed. Given two main elements/line
so it remains simple.

In each line have one element with grows and one sits with a basic
comfortably fixed size.
2024-05-20 10:40:50 +05:30
HanishKVC
c191e475d5 SimpleChat:HTML: Add viewport meta for better mobile friendliness
Without this the page content may look too small.
2024-05-19 15:51:07 +05:30
HanishKVC
5976126c26 SimpleChat:Readme: Note about handle_systemprompt begin/anytime 2024-05-19 03:42:44 +05:30
HanishKVC
7905f2fcbe SimpleChat:JS: Allow for changing system prompt anytime for future 2024-05-19 03:20:30 +05:30
HanishKVC
676053fc7f SimpleChat:HTML:Group user input+btn together; Note about multichat 2024-05-19 02:52:33 +05:30
HanishKVC
5a5f6ab848 SimpleChat: Update notes a bit. Try keep browser happy
Avoid browser quirk mode with DOCTYPE.

Help with accessibility a bit by specifying the language explicitly.

Specify the char encoding explicitly, inturn utf-8 is a safe bet,
even with intermixing of languages if reqd in future.

Add a cache-control http-equiv meta tag, which in all probability
will be ignored.

Defer js loading and execution, just for fun and future, not that
critical here as it stands now.
2024-05-19 01:59:25 +05:30
HanishKVC
6eb1e0fbde SimpleChat:JS: bottom of element visible, Set focus to user input
As the generated text could be multiple lines and occupy more space
that the full scrollable div's vertical space, make the bottom of
the last element (which can be such a generated text) in the div
visible by scrolling.

Ensure that the user input box has focus
2024-05-18 22:59:21 +05:30
HanishKVC
a944ce7cbe SimpleChat:JS: Try ensure the last entry in chat is visible
Needed because now only the chat div is scrollable and not the full
page.

In last commit the chat div size was fixed to 75% vertical height,
so the full page no longer scrolls, so the old bring user-input
element to view wont work, instead now the last element in the
chat div should be brought into view.
2024-05-18 22:23:34 +05:30
HanishKVC
a1a2f36a45 SimpleChat:CSS: Allow for chat div to be scrollable 2024-05-18 22:11:59 +05:30
HanishKVC
ebd5e71295 SimpleChat:CSS: Move style info into its own css file
To keep it simple, clean and seperate so that things are not
unnecessarily cluttered.
2024-05-18 17:09:47 +05:30
HanishKVC
65a56e6fdb SimpleChat: Update the readme file 2024-05-18 03:37:15 +05:30
HanishKVC
0d0a28b4ab SimpleChat:HTML: Add a style for system role message 2024-05-18 03:31:37 +05:30
HanishKVC
601fedf8c1 SimpleChat: Move handling systemprompt into its own func 2024-05-18 03:19:59 +05:30
HanishKVC
72151aa634 SimpleChat:Alert user if they provide sysprompt late or change it 2024-05-18 03:16:30 +05:30
HanishKVC
884adfd739 SimpleChat: Ignore empty user input, without trimming 2024-05-18 03:07:40 +05:30
HanishKVC
ae52ad1675 SimpleChat:Allow system prompt to be set, if provided before user 2024-05-18 02:59:42 +05:30
HanishKVC
69817fe1de SimpleChat:HTML: Cleanup/structure UI a bit, Add input for system 2024-05-18 01:40:57 +05:30
HanishKVC
668b98700c SimpleChat: Add a simple readme file 2024-05-18 01:06:54 +05:30
HanishKVC
b3644172e0 SimpleChat:JS: Force completion mode be single message by default 2024-05-18 00:36:23 +05:30
HanishKVC
aef32d9cc0 SimpleChat:JS: Handle difference in response
Try read the assistance response from appropriate field in the
response got.

Also examples/server seems to return the response in a slightly
different field, so try account for that also.
2024-05-18 00:36:23 +05:30
HanishKVC
3e5edbacd6 SimpleChat: Dont submit if already submitted and waiting
Also make chat the default selection wrt mode
2024-05-18 00:36:23 +05:30
HanishKVC
9feb58eaa5 SimpleChat: Allow user to select chat or completion mode 2024-05-18 00:36:23 +05:30
HanishKVC
e62087bf3f SimpleChat:JS: Try trap enter key press wrt input text field
So user can either press submit button or press enter key
2024-05-18 00:36:23 +05:30
HanishKVC
29d2d22c02 SimpleChat:sh: Add simple shell script to run python3 http.server
So one needs to run the llm server locally
then run this script and access it using a local browser
2024-05-18 00:36:23 +05:30
HanishKVC
ebe330d098 SimpleChat: Move into its own sub directory to avoid confusion 2024-05-18 00:36:23 +05:30
HanishKVC
9942851273 SimpleChat: Diff user/assistant msgs, Make input wider
Also show a default message to user

Also add some metas
2024-05-18 00:36:23 +05:30
HanishKVC
7d772f6b9a SimpleChat: Try keep input element in view 2024-05-18 00:36:23 +05:30