Fix tools-list
| @@ -612,3 +612,7 @@ ul.li-padding-bot5 li { | ||
| 612 | 612 | ul.li-padding-bot10 li { |
| 613 | 613 | padding-bottom: 10px; |
| 614 | 614 | } |
| 615 | + | |
| 616 | +.wordBreakAll { | |
| 617 | + word-break: break-all; | |
| 618 | +} | |
| @@ -58,7 +58,7 @@ export const slashCommandReturnHelper = { | ||
| 58 | 58 | case 'toast-html': { |
| 59 | 59 | const htmlOrNotHtml = shouldHtml ? DOMPurify.sanitize((new showdown.Converter()).makeHtml(stringValue)) : escapeHtml(stringValue); |
| 60 | 60 | |
| 61 | 61 | if (type.startsWith('popup')) await callGenericPopup(htmlOrNotHtml, POPUP_TYPE.TEXT, '', { allowVerticalScrolling: true, wide: true }); |
| 62 | 62 | if (type.startsWith('chat')) sendSystemMessage(system_message_types.GENERIC, htmlOrNotHtml); |
| 63 | 63 | if (type.startsWith('toast')) toastr.info(htmlOrNotHtml, null, { escapeHtml: !shouldHtml }); |
| 64 | 64 | |
| @@ -158,8 +158,8 @@ class ToolDefinition { | ||
| 158 | 158 | description: this.#description, |
| 159 | 159 | parameters: this.#parameters, |
| 160 | 160 | }, |
| 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>`; | |
| 163 | 163 | }, |
| 164 | 164 | }; |
| 165 | 165 | } |
| @@ -666,7 +666,7 @@ export class ToolManager { | ||
| 666 | 666 | callback: async (args) => { |
| 667 | 667 | /** @type {any} */ |
| 668 | 668 | 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(); | |
| 670 | 670 | const tools = ToolManager.tools.map(tool => tool.toFunctionOpenAI()); |
| 671 | 671 | return await slashCommandReturnHelper.doReturn(returnType ?? 'popup-html', tools ?? [], { objectToStringFunc }); |
| 672 | 672 | }, |