mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Prettify displayed message
This commit is contained in:
@ -342,7 +342,7 @@ export class ToolManager {
|
|||||||
|
|
||||||
// Save a successful invocation
|
// Save a successful invocation
|
||||||
if (result) {
|
if (result) {
|
||||||
invocations.push({ id, name, result, parameters });
|
invocations.push({ id, name, parameters, result });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -383,12 +383,16 @@ export class ToolManager {
|
|||||||
* @returns {string} Formatted message with tool invocations.
|
* @returns {string} Formatted message with tool invocations.
|
||||||
*/
|
*/
|
||||||
static #formatMessage(invocations) {
|
static #formatMessage(invocations) {
|
||||||
const toolNames = invocations.map(i => i.name).join(', ');
|
const tryParse = (x) => { try { return JSON.parse(x); } catch { return x; } };
|
||||||
|
const data = structuredClone(invocations);
|
||||||
const detailsElement = document.createElement('details');
|
const detailsElement = document.createElement('details');
|
||||||
const summaryElement = document.createElement('summary');
|
const summaryElement = document.createElement('summary');
|
||||||
const preElement = document.createElement('pre');
|
const preElement = document.createElement('pre');
|
||||||
const codeElement = document.createElement('code');
|
const codeElement = document.createElement('code');
|
||||||
codeElement.textContent = JSON.stringify(invocations, null, 2);
|
codeElement.classList.add('language-json');
|
||||||
|
data.forEach(i => i.parameters = tryParse(i.parameters));
|
||||||
|
codeElement.textContent = JSON.stringify(data, null, 2);
|
||||||
|
const toolNames = data.map(i => i.name).join(', ');
|
||||||
summaryElement.textContent = `Performed tool calls: ${toolNames}`;
|
summaryElement.textContent = `Performed tool calls: ${toolNames}`;
|
||||||
preElement.append(codeElement);
|
preElement.append(codeElement);
|
||||||
detailsElement.append(summaryElement, preElement);
|
detailsElement.append(summaryElement, preElement);
|
||||||
|
Reference in New Issue
Block a user