diff --git a/src/lib/components/chat/Messages/CodeBlock.svelte b/src/lib/components/chat/Messages/CodeBlock.svelte index ca69ce38d..31ed330a7 100644 --- a/src/lib/components/chat/Messages/CodeBlock.svelte +++ b/src/lib/components/chat/Messages/CodeBlock.svelte @@ -18,12 +18,17 @@ const dispatch = createEventDispatcher(); export let id = ''; + export let save = false; + export let run = true; export let token; export let lang = ''; export let code = ''; - export let allow_execution = true; + + export let className = 'my-2'; + export let editorClassName = ''; + export let stickyButtonsClassName = 'top-8'; let _code = ''; $: if (code) { @@ -297,7 +302,7 @@ __builtins__.input = input`);
-
+
{#if lang === 'mermaid'} {#if mermaidHtml}
{#if lang.toLowerCase() === 'python' || lang.toLowerCase() === 'py' || (lang === '' && checkPythonCode(code))} {#if executing}
Running
- {:else if allow_execution} + {:else if run}
-
- {#if codeExecution?.status == 'OK'} - ✅ - {:else if codeExecution?.status == 'ERROR'} - ❌ - {:else if codeExecution?.status == 'PENDING'} - ⏳ - {:else} - ⁉️ +
+ {#if codeExecution?.result} +
+ {#if codeExecution.result?.error} + + {:else if codeExecution.result?.output} + + {:else} + + {/if} +
{/if} - {#if codeExecution?.name} - {$i18n.t('Code execution')}: {codeExecution?.name} - {:else} - {$i18n.t('Code execution')} - {/if} +
+ {#if !codeExecution?.result} +
+ +
+ {/if} + +
+ {#if codeExecution?.name} + {$i18n.t('Code execution')}: {codeExecution?.name} + {:else} + {$i18n.t('Code execution')} + {/if} +
+
-
+
-
- {$i18n.t('Code')} -
-
- {#if codeExecution?.error} -
-
-
- {$i18n.t('Error')} -
- + {#if codeExecution?.result && (codeExecution?.result?.error || codeExecution?.result?.output)} +
+ {#if codeExecution?.result?.error} +
+
{$i18n.t('ERROR')}
+
{codeExecution?.result?.error}
+
+ {/if} + {#if codeExecution?.result?.output} +
+
{$i18n.t('OUTPUT')}
+
{codeExecution?.result?.output}
+
+ {/if}
{/if} - {#if codeExecution?.output} + {#if codeExecution?.result?.files && codeExecution?.result?.files.length > 0}
-
-
- {$i18n.t('Output')} -
- - -
- {/if} - {#if codeExecution?.files && codeExecution?.files.length > 0} -
-
+
{$i18n.t('Files')}
    - {#each codeExecution?.files as file} + {#each codeExecution?.result?.files as file}
  • - 💾 {file.name}
  • {/each} diff --git a/src/lib/components/chat/Messages/CodeExecutions.svelte b/src/lib/components/chat/Messages/CodeExecutions.svelte index ae3d47894..2c53eaeb3 100644 --- a/src/lib/components/chat/Messages/CodeExecutions.svelte +++ b/src/lib/components/chat/Messages/CodeExecutions.svelte @@ -1,38 +1,33 @@ {#if codeExecutions.length > 0}
    - {#each codeExecutions.map((execution) => { - let error = null; - let output = null; - let files = []; - let status = 'PENDING'; - - if (execution.result) { - output = execution.result.output; - if (execution.result.error) { - status = 'ERROR'; - error = execution.result.error; - } else { - status = 'OK'; - } - if (execution.result.files) { - files = execution.result.files; - } - } - - return { id: execution.id, name: execution.name, code: execution.code, language: execution.language || '', status: status, error: error, output: output, files: files }; - }) as execution (execution.id)} + {#each codeExecutions as execution (execution.id)}