mirror of
https://github.com/open-webui/open-webui
synced 2025-05-24 14:54:33 +00:00
refac
This commit is contained in:
parent
66015bb341
commit
c2ff73c3e1
@ -84,7 +84,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (floatingButtonsElement) {
|
if (floatingButtonsElement) {
|
||||||
floatingButtonsElement.closeHandler();
|
// check if closeHandler is defined
|
||||||
|
|
||||||
|
if (typeof floatingButtonsElement?.closeHandler === 'function') {
|
||||||
|
// call the closeHandler function
|
||||||
|
floatingButtonsElement?.closeHandler();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -52,6 +52,22 @@
|
|||||||
|
|
||||||
export let disabled = false;
|
export let disabled = false;
|
||||||
export let hide = false;
|
export let hide = false;
|
||||||
|
|
||||||
|
function formatJSONString(obj) {
|
||||||
|
try {
|
||||||
|
const parsed = JSON.parse(obj);
|
||||||
|
// If parsed is an object/array, then it's valid JSON
|
||||||
|
if (typeof parsed === 'object') {
|
||||||
|
return JSON.stringify(parsed, null, 2);
|
||||||
|
} else {
|
||||||
|
// It's a primitive value like a number, boolean, etc.
|
||||||
|
return String(parsed);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// Not valid JSON, return as-is
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div {id} class={className}>
|
<div {id} class={className}>
|
||||||
@ -176,19 +192,22 @@
|
|||||||
{#if open && !hide}
|
{#if open && !hide}
|
||||||
<div transition:slide={{ duration: 300, easing: quintOut, axis: 'y' }}>
|
<div transition:slide={{ duration: 300, easing: quintOut, axis: 'y' }}>
|
||||||
{#if attributes?.type === 'tool_calls'}
|
{#if attributes?.type === 'tool_calls'}
|
||||||
|
{@const args = JSON.parse(decode(attributes?.arguments))}
|
||||||
|
{@const result = JSON.parse(decode(attributes?.result ?? ''))}
|
||||||
|
|
||||||
{#if attributes?.done === 'true'}
|
{#if attributes?.done === 'true'}
|
||||||
<Markdown
|
<Markdown
|
||||||
id={`tool-calls-${attributes?.id}-result`}
|
id={`tool-calls-${attributes?.id}-result`}
|
||||||
content={`> \`\`\`json
|
content={`> \`\`\`json
|
||||||
> ${JSON.stringify(JSON.parse(JSON.parse(decode(attributes?.arguments))), null, 2)}
|
> ${formatJSONString(args)}
|
||||||
> ${JSON.stringify(JSON.parse(JSON.parse(decode(attributes?.result))), null, 2)}
|
> ${formatJSONString(result)}
|
||||||
> \`\`\``}
|
> \`\`\``}
|
||||||
/>
|
/>
|
||||||
{:else}
|
{:else}
|
||||||
<Markdown
|
<Markdown
|
||||||
id={`tool-calls-${attributes?.id}-result`}
|
id={`tool-calls-${attributes?.id}-result`}
|
||||||
content={`> \`\`\`json
|
content={`> \`\`\`json
|
||||||
> ${JSON.stringify(JSON.parse(JSON.parse(decode(attributes?.arguments))), null, 2)}
|
> ${formatJSONString(args)}
|
||||||
> \`\`\``}
|
> \`\`\``}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
Loading…
Reference in New Issue
Block a user