diff --git a/frontend/src/components/message-box.mjs b/frontend/src/components/message-box.mjs index 924bfe3..0d8fa39 100644 --- a/frontend/src/components/message-box.mjs +++ b/frontend/src/components/message-box.mjs @@ -63,7 +63,7 @@ export class MessageBox extends LitElement {

AI:

${this.toolCalls.map((tool, toolIndex) => html` - + `)} ${this.content ? html` @@ -125,7 +125,7 @@ export class MessageBox extends LitElement { // parse response data /** - * @type { {type?: 'tool' | 'content' | 'end', data?: any} } + * @type { {type?: 'tool' | 'tool-response' | 'content' | 'end', data?: any} } */ let response = {}; try { @@ -135,10 +135,14 @@ export class MessageBox extends LitElement { return; } - // It's a tool + // It's a tool call if (response.type === 'tool') { this.toolCalls = [...this.toolCalls, response.data[0]]; + // It's a tool response + } else if (response.type === 'tool-response') { + this.toolCalls[this.toolCalls.length - 1].response = response.data; + // It's the text response } else if (response.type === 'content') { this.content += response.data; diff --git a/frontend/src/components/tool-info.mjs b/frontend/src/components/tool-info.mjs index 6cbfeb9..9d31ca2 100644 --- a/frontend/src/components/tool-info.mjs +++ b/frontend/src/components/tool-info.mjs @@ -11,7 +11,8 @@ const ToolInfo = class extends LitElement { static properties = { name: { type: String, attribute: 'name' }, server: { type: String, attribute: 'server' }, - entries: { type: Object, attribute: 'entries' }, + parameters: { type: Object, attribute: 'parameters' }, + response: { type: String, attribute: 'response' }, ref: { type: String, attribute: 'ref' }, inUse: { type: String, attribute: 'in-use' }, }; @@ -35,6 +36,7 @@ const ToolInfo = class extends LitElement {
+

Parameters

@@ -43,8 +45,8 @@ const ToolInfo = class extends LitElement { - ${this.entries ? html` - ${Object.entries(this.entries).map(([key, value]) => html` + ${this.parameters ? html` + ${Object.entries(this.parameters).map(([key, value]) => html` @@ -53,6 +55,8 @@ const ToolInfo = class extends LitElement { ` : ''}
${key}: ${typeof value === 'string' ? value : JSON.stringify(value)}
+

Response

+

${this.response}

`; } diff --git a/frontend/src/logic/ai3.ts b/frontend/src/logic/ai3.ts index 2b550ca..8d15b3b 100644 --- a/frontend/src/logic/ai3.ts +++ b/frontend/src/logic/ai3.ts @@ -166,6 +166,16 @@ export const getLlmResponse = async(messages: Message[], selectedServers: FormDa }), sessionToken); } } + + // Tool response + if (chunk.tools?.messages) { + toolCalls[toolCalls.length - 1].response = chunk.tools.messages[0].content; + sendMessage(JSON.stringify({ + type: 'tool-response', + data: chunk.tools.messages[0].content, + }), sessionToken); + } + } return {