Fix tools-list

96862be6b02a4a0b4a9ff13ed7ca2486c8ea89f8

Cohee <18619528+Cohee1207@users.noreply.github.com>

3 files changed, +8 -4Ignore whitespace
public/css/st-tailwind.css+4 -0
@@ -612,3 +612,7 @@ ul.li-padding-bot5 li {
612612ul.li-padding-bot10 li {
613613 padding-bottom: 10px;
614614}
615+
616+.wordBreakAll {
617+ word-break: break-all;
618+}
public/scripts/slash-commands/SlashCommandReturnHelper.js+1 -1
@@ -58,7 +58,7 @@ export const slashCommandReturnHelper = {
5858 case 'toast-html': {
5959 const htmlOrNotHtml = shouldHtml ? DOMPurify.sanitize((new showdown.Converter()).makeHtml(stringValue)) : escapeHtml(stringValue);
6060
6161 if (type.startsWith('popup')) await callGenericPopup(htmlOrNotHtml, POPUP_TYPE.TEXT, '', { allowVerticalScrolling: true, wide: true });
6262 if (type.startsWith('chat')) sendSystemMessage(system_message_types.GENERIC, htmlOrNotHtml);
6363 if (type.startsWith('toast')) toastr.info(htmlOrNotHtml, null, { escapeHtml: !shouldHtml });
6464
public/scripts/tool-calling.js+3 -3
@@ -158,8 +158,8 @@ class ToolDefinition {
158158 description: this.#description,
159159 parameters: this.#parameters,
160160 },
161- toString: (/** @type {ToolDefinitionOpenAI} */ tool) => {
161+ toString: function() {
162- return `${tool?.function?.name} - ${tool?.function?.description}\n${JSON.stringify(tool?.function?.parameters, null, 2)}`;
162+ return `<div><b>${this.function.name}</b></div><div><small>${this.function.description}</small></div><pre class="justifyLeft wordBreakAll"><code class="flex padding5">${JSON.stringify(this.function.parameters, null, 2)}</code></pre><hr>`;
163163 },
164164 };
165165 }
@@ -666,7 +666,7 @@ export class ToolManager {
666666 callback: async (args) => {
667667 /** @type {any} */
668668 const returnType = String(args?.return ?? 'popup-html').trim().toLowerCase();
669- const objectToStringFunc = (tool) => tool.toString();
669+ const objectToStringFunc = (tools) => Array.isArray(tools) ? tools.map(x => x.toString()).join('\n\n') : tools.toString();
670670 const tools = ToolManager.tools.map(tool => tool.toFunctionOpenAI());
671671 return await slashCommandReturnHelper.doReturn(returnType ?? 'popup-html', tools ?? [], { objectToStringFunc });
672672 },