SimpleChatTCRV:Config++: ValidatedToolCall UI updated

Given that ValidatedToolCallTrigger UI setup has to also setup
the auto trigger logic, which inturn is dependent on the autosecs
value in the Config associated with the Chat session involved, so
pass chatId to ShowMessage and inturn ValidatedToolCallTriggerUI
setup logic

Rename the function name to better match the semantic.
This commit is contained in:
hanishkvc 2025-11-23 15:35:39 +05:30
parent 8e39afb05e
commit 7d6971a737
2 changed files with 34 additions and 21 deletions

View File

@ -867,15 +867,28 @@ Cleanup in general
end user can see the streamed response from that chat session as it is occuring. end user can see the streamed response from that chat session as it is occuring.
* Cleanup the tool call descriptions and verbose messages returned a bit. * Cleanup the tool call descriptions and verbose messages returned a bit.
* Move towards Chat Session specific settings * Move towards Chat Session specific settings
* Needed so that one could
* setup a different ai model / engine as the external ai backend.
* interact with different independent ai models / engines / parallel instances in general
* Move needed configs from Me into a seperate Config class. * Move needed configs from Me into a seperate Config class.
* also move ShowSettings, ShowInfo etal into Config class * also move ShowSettings, ShowInfo etal into Config class
* SimpleChat maintains an instance of Config class instead of Me. * SimpleChat maintains an instance of Config class instead of Me.
* Update starting flow to create the default set of chat sessions, setup ui etal after toolsMgr init * ToolsManager and the different tool call modules have been updated to
* TODO: Rather temporarily for now, to ensure tools name etal get populated. * have seperate init and setup calls.
* TODO: May need to have seperate partial tools manager per chat session, if we allow the proxyUrl * init is called at the begining
to be decided at a per chat session basis. * setup will be called when ever a chat session is being created
* TODO: Rather current flow expects any changed proxyUrl to reflect what ever was supported by and or in future when ever any config of interest changes.
default proxyUrl * pick needed config etal from the specified chatId's config and not any global config.
* Starting flow updated to chain the different logical blocks of code
* first allow tools manager to be initd
* next create the needed default set of sessions, while parallely calling tool manager setup as needed.
* ensures that the available list of tool calls match the config of the chat session involved.
Needed as user could change tools related proxy server url.
* next setup the main ui as needed.
* TODO
* Need to save and restore ChatSession config entries.
* Need to allow any changes to proxyUrl to trigger a new tool manager setup wrt that chat session.
* Need to hide user-input area and tool call validate/trigger area when switching into settings
#### ToDo #### ToDo
@ -894,9 +907,6 @@ the simpleproxy.py if and where needed.
Save used config entries along with the auto saved chat sessions and inturn give option to reload the Save used config entries along with the auto saved chat sessions and inturn give option to reload the
same when saved chat is loaded. same when saved chat is loaded.
MAYBE make the settings in general chat session specific, rather than the current global config flow.
Rather for now having a global settings seems to make more sense, so dont change for now.
Have a seperate helper to show the user input area, based on set state. And have support for multiple images Have a seperate helper to show the user input area, based on set state. And have support for multiple images
if the models support same. It should also take care of some aspects of the tool call response edit / submit, if the models support same. It should also take care of some aspects of the tool call response edit / submit,
potentially. potentially.

View File

@ -1238,21 +1238,23 @@ class MultiChatUI {
} }
/** /**
* Reset/Setup Tool Call UI parts as needed * Setup/Reset Validated Tool Call UI parts as needed
* @param {ChatMessageEx} ar * @param {ChatMessageEx} ar
* @param {string} chatId
* @param {boolean} bAuto - allows caller to explicitly control whether auto triggering should be setup. * @param {boolean} bAuto - allows caller to explicitly control whether auto triggering should be setup.
*/ */
ui_reset_toolcall_as_needed(ar, bAuto = false) { ui_toolcallvalidated_as_needed(ar, chatId = "", bAuto = false) {
if (ar.ns.has_toolcalls()) { if (ar.ns.has_toolcalls()) {
this.elDivTool.hidden = false this.elDivTool.hidden = false
this.elInToolName.value = ar.ns.getFuncName(0) this.elInToolName.value = ar.ns.getFuncName(0)
this.elInToolName.dataset.tool_call_id = ar.ns.getFunc(0)?.id this.elInToolName.dataset.tool_call_id = ar.ns.getFunc(0)?.id
this.elInToolArgs.value = `${ar.ns.getFunc(0)?.function.arguments}` this.elInToolArgs.value = `${ar.ns.getFunc(0)?.function.arguments}`
this.elBtnTool.disabled = false this.elBtnTool.disabled = false
if ((this.me.tools.autoSecs > 0) && (bAuto)) { let chat = this.simpleChats[chatId]
if ((chat) && (chat.cfg.tools.autoSecs > 0) && (bAuto)) {
this.timers.toolcallTriggerClick = setTimeout(()=>{ this.timers.toolcallTriggerClick = setTimeout(()=>{
this.elBtnTool.click() this.elBtnTool.click()
}, this.me.tools.autoSecs*this.TimePeriods.ToolCallAutoSecsTimeUnit) }, chat.cfg.tools.autoSecs*this.TimePeriods.ToolCallAutoSecsTimeUnit)
} }
} else { } else {
this.elDivTool.hidden = true this.elDivTool.hidden = true
@ -1363,11 +1365,12 @@ class MultiChatUI {
* * if it is the last message OR * * if it is the last message OR
* * if it is the last but one message and there is a ToolTemp message next * * if it is the last but one message and there is a ToolTemp message next
* @param {HTMLElement | undefined} elParent * @param {HTMLElement | undefined} elParent
* @param {string} chatId
* @param {ChatMessageEx} msg * @param {ChatMessageEx} msg
* @param {number} iFromLast * @param {number} iFromLast
* @param {ChatMessageEx | undefined} nextMsg * @param {ChatMessageEx | undefined} nextMsg
*/ */
show_message(elParent, msg, iFromLast, nextMsg) { show_message(elParent, chatId, msg, iFromLast, nextMsg) {
// Handle ToolTemp // Handle ToolTemp
if (iFromLast == 0) { if (iFromLast == 0) {
if (msg.ns.role === Roles.ToolTemp) { if (msg.ns.role === Roles.ToolTemp) {
@ -1457,7 +1460,7 @@ class MultiChatUI {
} }
} }
if (bTC) { if (bTC) {
this.ui_reset_toolcall_as_needed(msg, bAuto); this.ui_toolcallvalidated_as_needed(msg, chatId, bAuto);
} }
} }
// Handle tool call message show // Handle tool call message show
@ -1495,7 +1498,7 @@ class MultiChatUI {
this.ui_userinput_reset() this.ui_userinput_reset()
this.elDivStreams[chatId]?.clear() this.elDivStreams[chatId]?.clear()
} }
this.ui_reset_toolcall_as_needed(new ChatMessageEx()); this.ui_toolcallvalidated_as_needed(new ChatMessageEx());
this.elLastChatMessage = null this.elLastChatMessage = null
let chatToShow = chat.recent_chat(chat.cfg.chatProps.iRecentUserMsgCnt); let chatToShow = chat.recent_chat(chat.cfg.chatProps.iRecentUserMsgCnt);
for(const [i, x] of chatToShow.entries()) { for(const [i, x] of chatToShow.entries()) {
@ -1504,7 +1507,7 @@ class MultiChatUI {
if (iFromLast == 1) { if (iFromLast == 1) {
nextMsg = chatToShow[i+1] nextMsg = chatToShow[i+1]
} }
this.show_message(this.elDivChat, x, iFromLast, nextMsg) this.show_message(this.elDivChat, chat.chatId, x, iFromLast, nextMsg)
} }
this.elDivChat.appendChild(this.elDivStreams[chatId].div) this.elDivChat.appendChild(this.elDivStreams[chatId].div)
this.elDivChat.appendChild(this.elDivStreams[AI_TC_SESSIONNAME].div) this.elDivChat.appendChild(this.elDivStreams[AI_TC_SESSIONNAME].div)
@ -1557,13 +1560,13 @@ class MultiChatUI {
return this.chat_show(chatId, true, true) return this.chat_show(chatId, true, true)
} }
this.ui_userinput_reset(false) this.ui_userinput_reset(false)
this.ui_reset_toolcall_as_needed(new ChatMessageEx()); this.ui_toolcallvalidated_as_needed(new ChatMessageEx());
for(let i=lastN; i > 0; i-=1) { for(let i=lastN; i > 0; i-=1) {
let msg = chat.xchat[chat.xchat.length-i] let msg = chat.xchat[chat.xchat.length-i]
let nextMsg = chat.xchat[chat.xchat.length-(i-1)] let nextMsg = chat.xchat[chat.xchat.length-(i-1)]
if (msg) { if (msg) {
this.chatmsg_ui_remove(msg.uniqId) this.chatmsg_ui_remove(msg.uniqId)
this.show_message(this.elDivChat, msg, (i-1), nextMsg) this.show_message(this.elDivChat, chat.chatId, msg, (i-1), nextMsg)
} }
} }
if (!this.elDivChat.contains(this.elDivStreams[chatId].div)) { if (!this.elDivChat.contains(this.elDivStreams[chatId].div)) {
@ -1625,7 +1628,7 @@ class MultiChatUI {
this.handle_session_switch(this.curChatId); this.handle_session_switch(this.curChatId);
} }
this.ui_reset_toolcall_as_needed(new ChatMessageEx()); this.ui_toolcallvalidated_as_needed(new ChatMessageEx());
this.elBtnSettings.addEventListener("click", (ev)=>{ this.elBtnSettings.addEventListener("click", (ev)=>{
this.elDivChat.replaceChildren(); this.elDivChat.replaceChildren();
@ -1776,7 +1779,7 @@ class MultiChatUI {
chat.clear(); chat.clear();
} }
this.ui_reset_toolcall_as_needed(new ChatMessageEx()); this.ui_toolcallvalidated_as_needed(new ChatMessageEx());
chat.add_system_anytime(this.elInSystem.value, chatId); chat.add_system_anytime(this.elInSystem.value, chatId);