diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte index 83e3b967f..d84f503da 100644 --- a/src/lib/components/chat/Chat.svelte +++ b/src/lib/components/chat/Chat.svelte @@ -175,10 +175,30 @@ message.statusHistory = [data]; } } else if (type === 'citation') { - if (message?.citations) { - message.citations.push(data); + if (data?.type === 'code_execution') { + // Code execution; update existing code execution by UUID, + // otherwise append. + if (!message?.code_executions) { + message.code_executions = []; + } + let is_update = false; + for (let i = 0; i < message.code_executions.length; i++) { + if (message.code_executions[i].uuid === data.uuid) { + message.code_executions[i] = data; + is_update = true; + break; + } + } + if (!is_update) { + message.code_executions.push(data); + } } else { - message.citations = [data]; + // Regular citation. + if (message?.citations) { + message.citations.push(data); + } else { + message.citations = [data]; + } } } else if (type === 'message') { message.content += data.content; diff --git a/src/lib/components/chat/Messages/CodeBlock.svelte b/src/lib/components/chat/Messages/CodeBlock.svelte index ef17c493a..ca69ce38d 100644 --- a/src/lib/components/chat/Messages/CodeBlock.svelte +++ b/src/lib/components/chat/Messages/CodeBlock.svelte @@ -23,6 +23,7 @@ export let token; export let lang = ''; export let code = ''; + export let allow_execution = true; let _code = ''; $: if (code) { @@ -319,7 +320,7 @@ __builtins__.input = input`); {#if lang.toLowerCase() === 'python' || lang.toLowerCase() === 'py' || (lang === '' && checkPythonCode(code))} {#if executing}
- {:else} + {:else if allow_execution}