mirror of
https://github.com/open-webui/open-webui
synced 2025-06-26 18:26:48 +00:00
enh: jupyter matplotlib support
This commit is contained in:
parent
2ee09d9f7d
commit
003968f06a
@ -130,9 +130,65 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (output) {
|
if (output) {
|
||||||
stdout = output.stdout;
|
if (output['stdout']) {
|
||||||
stderr = output.stderr;
|
stdout = output['stdout'];
|
||||||
result = output.result;
|
const stdoutLines = stdout.split('\n');
|
||||||
|
|
||||||
|
for (const [idx, line] of stdoutLines.entries()) {
|
||||||
|
if (line.startsWith('data:image/png;base64')) {
|
||||||
|
if (files) {
|
||||||
|
files.push({
|
||||||
|
type: 'image/png',
|
||||||
|
data: line
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
files = [
|
||||||
|
{
|
||||||
|
type: 'image/png',
|
||||||
|
data: line
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stdout.startsWith(`${line}\n`)) {
|
||||||
|
stdout = stdout.replace(`${line}\n`, ``);
|
||||||
|
} else if (stdout.startsWith(`${line}`)) {
|
||||||
|
stdout = stdout.replace(`${line}`, ``);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (output['result']) {
|
||||||
|
result = output['result'];
|
||||||
|
const resultLines = result.split('\n');
|
||||||
|
|
||||||
|
for (const [idx, line] of resultLines.entries()) {
|
||||||
|
if (line.startsWith('data:image/png;base64')) {
|
||||||
|
if (files) {
|
||||||
|
files.push({
|
||||||
|
type: 'image/png',
|
||||||
|
data: line
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
files = [
|
||||||
|
{
|
||||||
|
type: 'image/png',
|
||||||
|
data: line
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result.startsWith(`${line}\n`)) {
|
||||||
|
result = result.replace(`${line}\n`, ``);
|
||||||
|
} else if (result.startsWith(`${line}`)) {
|
||||||
|
result = result.replace(`${line}`, ``);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
output['stderr'] && (stderr = output['stderr']);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
executePythonAsWorker(code);
|
executePythonAsWorker(code);
|
||||||
@ -205,7 +261,40 @@
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
stdout = stdout.replace(`${line}\n`, ``);
|
if (stdout.startsWith(`${line}\n`)) {
|
||||||
|
stdout = stdout.replace(`${line}\n`, ``);
|
||||||
|
} else if (stdout.startsWith(`${line}`)) {
|
||||||
|
stdout = stdout.replace(`${line}`, ``);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data['result']) {
|
||||||
|
result = data['result'];
|
||||||
|
const resultLines = result.split('\n');
|
||||||
|
|
||||||
|
for (const [idx, line] of resultLines.entries()) {
|
||||||
|
if (line.startsWith('data:image/png;base64')) {
|
||||||
|
if (files) {
|
||||||
|
files.push({
|
||||||
|
type: 'image/png',
|
||||||
|
data: line
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
files = [
|
||||||
|
{
|
||||||
|
type: 'image/png',
|
||||||
|
data: line
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result.startsWith(`${line}\n`)) {
|
||||||
|
result = result.replace(`${line}\n`, ``);
|
||||||
|
} else if (result.startsWith(`${line}`)) {
|
||||||
|
result = result.replace(`${line}`, ``);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -391,7 +480,7 @@
|
|||||||
class="bg-gray-50 dark:bg-[#202123] dark:text-white max-w-full overflow-x-auto scrollbar-hidden"
|
class="bg-gray-50 dark:bg-[#202123] dark:text-white max-w-full overflow-x-auto scrollbar-hidden"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{#if executing || stdout || stderr || result}
|
{#if executing || stdout || stderr || result || files}
|
||||||
<div
|
<div
|
||||||
class="bg-gray-50 dark:bg-[#202123] dark:text-white rounded-b-lg! py-4 px-4 flex flex-col gap-2"
|
class="bg-gray-50 dark:bg-[#202123] dark:text-white rounded-b-lg! py-4 px-4 flex flex-col gap-2"
|
||||||
>
|
>
|
||||||
|
Loading…
Reference in New Issue
Block a user