SimpleChatTCRV:ToolCall:ExternalAi: Show its response live
Include the DivStream of ExternalAi toolcall in the other chat session UIs, so that user can see what the external_ai toolcall is doing, without having to switch out to external ai session tab. Update the name of the tool call external ai session. Ensure to clear previous chat session wrt external ai tool calls As the ai may call external ai toolcall with the same system prompt sometimes, which wont trigger the autoclear logic, wrt the corresponding chat session. TODO: In future maybe provide a option to continue any previous chat session if the system prompt is not changed wrt external ai toolcall.
This commit is contained in:
parent
97ba0cbf43
commit
fe0e118a6b
|
|
@ -857,7 +857,8 @@ Cleanup in general
|
|||
* Allow user to load multiple images and submit to ai as part of a single user message.
|
||||
* Use popover ui to allow user to view larger versions of loaded images as well as remove before submitting
|
||||
to ai, if and when needed.
|
||||
* add external_ai toolcall
|
||||
* add external_ai toolcall, user can see the response being generated by the external ai tool call,
|
||||
as it is getting generated and recieved.
|
||||
* maintain chat session specific DivStream elements, so that in future, if the logic is updated to allow
|
||||
switching in the middle of a pending tool call or pending ai server response, things dont mess up wrt
|
||||
ui, as they will be updating their respective DivStream and switching sessions will also take care of
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ const TEMP_MARKER = "-TEMP"
|
|||
const DB_NAME = "SimpleChatTCRV"
|
||||
const DB_STORE = "Sessions"
|
||||
|
||||
export const AI_TC_SESSIONNAME = `ExternalAI${TEMP_MARKER}`
|
||||
export const AI_TC_SESSIONNAME = `TCExternalAI`
|
||||
|
||||
const ROLES_TEMP_ENDSWITH = TEMP_MARKER
|
||||
|
||||
|
|
@ -924,7 +924,7 @@ class SimpleChat {
|
|||
throw Error("ERRR:SimpleChat:SC:HandleResponseMultiPart:No body...");
|
||||
}
|
||||
let elDivStream = elDivStreams[this.chatId];
|
||||
elDivStream.divRole.innerText = `Ai:${this.chatId.slice(0,6)}`
|
||||
elDivStream.divRole.innerText = `Ai:${this.chatId.slice(0,8)}`
|
||||
elDivStream.show()
|
||||
try {
|
||||
let tdUtf8 = new TextDecoder("utf-8");
|
||||
|
|
@ -1496,6 +1496,7 @@ class MultiChatUI {
|
|||
this.show_message(this.elDivChat, x, iFromLast, nextMsg)
|
||||
}
|
||||
this.elDivChat.appendChild(this.elDivStreams[chatId].div)
|
||||
this.elDivChat.appendChild(this.elDivStreams[AI_TC_SESSIONNAME].div)
|
||||
if (this.elLastChatMessage != null) {
|
||||
this.scroll_el_into_view(this.elLastChatMessage)
|
||||
} else {
|
||||
|
|
@ -1558,6 +1559,7 @@ class MultiChatUI {
|
|||
console.log(`DBUG:SimpleChat:MCUI:UiRefresh:${chatId}: DivStream ${this.elDivStreams[chatId].div.id} missing...`)
|
||||
}
|
||||
this.elDivChat.appendChild(this.elDivStreams[chatId].div)
|
||||
this.elDivChat.appendChild(this.elDivStreams[AI_TC_SESSIONNAME].div)
|
||||
if (this.elLastChatMessage != null) {
|
||||
this.scroll_el_into_view(this.elLastChatMessage)
|
||||
}
|
||||
|
|
@ -1726,6 +1728,7 @@ class MultiChatUI {
|
|||
new_chat_session(chatId, bSwitchSession=false) {
|
||||
this.simpleChats[chatId] = new SimpleChat(chatId, this.me);
|
||||
this.elDivStreams[chatId] = new ELDivStream(chatId);
|
||||
this.elDivStreams[chatId].clear()
|
||||
if (bSwitchSession) {
|
||||
this.handle_session_switch(chatId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ let externalai_meta = {
|
|||
*/
|
||||
function externalai_run(chatid, toolcallid, toolname, obj) {
|
||||
let sc = gMe.multiChat.simpleChats[mChatMagic.AI_TC_SESSIONNAME];
|
||||
|
||||
sc.clear()
|
||||
sc.add_system_anytime(obj['system_prompt'], 'TC:ExternalAI')
|
||||
sc.add(new mChatMagic.ChatMessageEx(new mChatMagic.NSChatMessage(mChatMagic.Roles.User, obj['user_message'])))
|
||||
sc.handle_chat_hs(gMe.baseURL, mChatMagic.ApiEP.Type.Chat, { chatPropsStream: gMe.chatProps.stream, toolsEnabled: false }, gMe.multiChat.elDivStreams).then((resp)=>{
|
||||
|
|
|
|||
Loading…
Reference in New Issue