mirror of
https://github.com/open-webui/open-webui
synced 2025-01-18 00:30:51 +00:00
refac
This commit is contained in:
parent
9bd5567552
commit
457360dae7
@ -200,9 +200,16 @@
|
||||
eventConfirmationTitle = data.title;
|
||||
eventConfirmationMessage = data.message;
|
||||
} else if (type === 'execute') {
|
||||
eventCallback = cb;
|
||||
|
||||
try {
|
||||
// Use Function constructor to evaluate code in a safer way
|
||||
new Function(data.code)();
|
||||
const asyncFunction = new Function(`return (async () => { ${data.code} })()`);
|
||||
const result = await asyncFunction(); // Await the result of the async function
|
||||
|
||||
if (cb) {
|
||||
cb(result);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error executing code:', error);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user