mirror of
https://github.com/open-webui/open-webui.git
synced 2025-04-11 21:39:07 +02:00
enh: pyodide python result handling
This commit is contained in:
parent
b94b691993
commit
74172461c7
@ -379,15 +379,27 @@ __builtins__.input = input`);
|
||||
class="bg-[#202123] text-white max-w-full overflow-x-auto scrollbar-hidden"
|
||||
/>
|
||||
|
||||
{#if executing}
|
||||
<div class="bg-[#202123] text-white px-4 py-4 rounded-b-lg">
|
||||
<div class=" text-gray-500 text-xs mb-1">STDOUT/STDERR</div>
|
||||
<div class="text-sm">Running...</div>
|
||||
</div>
|
||||
{:else if stdout || stderr || result}
|
||||
<div class="bg-[#202123] text-white px-4 py-4 rounded-b-lg">
|
||||
<div class=" text-gray-500 text-xs mb-1">STDOUT/STDERR</div>
|
||||
<div class="text-sm">{stdout || stderr || result}</div>
|
||||
{#if executing || stdout || stderr || result}
|
||||
<div class="bg-[#202123] text-white !rounded-b-lg py-4 px-4 flex flex-col gap-2">
|
||||
{#if executing}
|
||||
<div class=" ">
|
||||
<div class=" text-gray-500 text-xs mb-1">STDOUT/STDERR</div>
|
||||
<div class="text-sm">Running...</div>
|
||||
</div>
|
||||
{:else}
|
||||
{#if stdout || stderr}
|
||||
<div class=" ">
|
||||
<div class=" text-gray-500 text-xs mb-1">STDOUT/STDERR</div>
|
||||
<div class="text-sm">{stdout || stderr}</div>
|
||||
</div>
|
||||
{/if}
|
||||
{#if result}
|
||||
<div class=" ">
|
||||
<div class=" text-gray-500 text-xs mb-1">RESULT</div>
|
||||
<div class="text-sm">{`${result}`}</div>
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
|
@ -61,9 +61,16 @@ self.onmessage = async (event) => {
|
||||
|
||||
try {
|
||||
self.result = await self.pyodide.runPythonAsync(code);
|
||||
|
||||
try {
|
||||
self.result = self.result.toJSON();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
} catch (error) {
|
||||
self.stderr = error.toString();
|
||||
}
|
||||
|
||||
self.postMessage({ id, result: self.result, stdout: self.stdout, stderr: self.stderr });
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user