mirror of
https://github.com/ParisNeo/lollms-webui.git
synced 2025-01-30 08:03:57 +00:00
Enhanced code execution
This commit is contained in:
parent
5d8e8c7fcc
commit
68fed9326b
4
app.py
4
app.py
@ -53,7 +53,7 @@ try:
|
|||||||
from lollms.binding import LOLLMSConfig, BindingBuilder
|
from lollms.binding import LOLLMSConfig, BindingBuilder
|
||||||
from lollms.personality import AIPersonality
|
from lollms.personality import AIPersonality
|
||||||
from lollms.config import BaseConfig
|
from lollms.config import BaseConfig
|
||||||
from lollms.helpers import ASCIIColors, trace_exception
|
from lollms.helpers import ASCIIColors, get_trace_exception, trace_exception
|
||||||
from lollms.paths import LollmsPaths
|
from lollms.paths import LollmsPaths
|
||||||
|
|
||||||
from api.db import Discussion
|
from api.db import Discussion
|
||||||
@ -443,7 +443,7 @@ class LoLLMsWebUI(LoLLMsAPPI):
|
|||||||
# Get the output.
|
# Get the output.
|
||||||
output = interpreter.getvalue()
|
output = interpreter.getvalue()
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
output = str(ex)
|
output = str(ex)+"\n"+get_trace_exception(ex)
|
||||||
end_time = time.time()
|
end_time = time.time()
|
||||||
|
|
||||||
return jsonify({"output":output,"execution_time":end_time - start_time})
|
return jsonify({"output":output,"execution_time":end_time - start_time})
|
||||||
|
File diff suppressed because one or more lines are too long
2
web/dist/index.html
vendored
2
web/dist/index.html
vendored
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>LoLLMS WebUI - Welcome</title>
|
<title>LoLLMS WebUI - Welcome</title>
|
||||||
<script type="module" crossorigin src="/assets/index-31e94240.js"></script>
|
<script type="module" crossorigin src="/assets/index-19fca3d7.js"></script>
|
||||||
<link rel="stylesheet" href="/assets/index-90cbdba9.css">
|
<link rel="stylesheet" href="/assets/index-90cbdba9.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
@ -69,12 +69,16 @@ const markdownIt = new MarkdownIt('commonmark', {
|
|||||||
'" class="overflow-x-auto break-all scrollbar-thin scrollbar-track-bg-light-tone scrollbar-thumb-bg-light-tone-panel hover:scrollbar-thumb-primary dark:scrollbar-track-bg-dark-tone dark:scrollbar-thumb-bg-dark-tone-panel dark:hover:scrollbar-thumb-primary active:scrollbar-thumb-secondary">' +
|
'" class="overflow-x-auto break-all scrollbar-thin scrollbar-track-bg-light-tone scrollbar-thumb-bg-light-tone-panel hover:scrollbar-thumb-primary dark:scrollbar-track-bg-dark-tone dark:scrollbar-thumb-bg-dark-tone-panel dark:hover:scrollbar-thumb-primary active:scrollbar-thumb-secondary">' +
|
||||||
highlightedCode +
|
highlightedCode +
|
||||||
'</code>' +
|
'</code>' +
|
||||||
|
'</pre>' +
|
||||||
|
'<pre id="pre_exec_' +
|
||||||
|
id + '" class="hljs p-1 hidden rounded-md break-all grid grid-cols-1 mt-2">' +
|
||||||
|
'Execution output:<br>' +
|
||||||
'<code id="code_exec_' +
|
'<code id="code_exec_' +
|
||||||
id +
|
id +
|
||||||
'" class="overflow-x-auto hidden break-all scrollbar-thin scrollbar-track-bg-light-tone scrollbar-thumb-bg-light-tone-panel hover:scrollbar-thumb-primary dark:scrollbar-track-bg-dark-tone dark:scrollbar-thumb-bg-dark-tone-panel dark:hover:scrollbar-thumb-primary active:scrollbar-thumb-secondary">' +
|
'" class="overflow-x-auto break-all scrollbar-thin scrollbar-track-bg-light-tone scrollbar-thumb-bg-light-tone-panel hover:scrollbar-thumb-primary dark:scrollbar-track-bg-dark-tone dark:scrollbar-thumb-bg-dark-tone-panel dark:hover:scrollbar-thumb-primary active:scrollbar-thumb-secondary">' +
|
||||||
'</code>' +
|
'</code>' +
|
||||||
|
|
||||||
'</pre>' +
|
'</pre>' +
|
||||||
|
|
||||||
'</div>'
|
'</div>'
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -116,13 +120,13 @@ const markdownIt = new MarkdownIt('commonmark', {
|
|||||||
'</code>' +
|
'</code>' +
|
||||||
'<code id="code_exec_' +
|
'<code id="code_exec_' +
|
||||||
id +
|
id +
|
||||||
'" class="overflow-x-auto hidden break-all scrollbar-thin scrollbar-track-bg-light-tone scrollbar-thumb-bg-light-tone-panel hover:scrollbar-thumb-primary dark:scrollbar-track-bg-dark-tone dark:scrollbar-thumb-bg-dark-tone-panel dark:hover:scrollbar-thumb-primary active:scrollbar-thumb-secondary">' +
|
'" class="overflow-x-auto mt-2 hidden break-all scrollbar-thin scrollbar-track-bg-light-tone scrollbar-thumb-bg-light-tone-panel hover:scrollbar-thumb-primary dark:scrollbar-track-bg-dark-tone dark:scrollbar-thumb-bg-dark-tone-panel dark:hover:scrollbar-thumb-primary active:scrollbar-thumb-secondary">' +
|
||||||
'</code>' +
|
'</code>' +
|
||||||
'</pre>' +
|
'</pre>' +
|
||||||
'</div>';
|
'</div>';
|
||||||
return codeString;
|
return codeString;
|
||||||
},
|
},
|
||||||
bulletListMarker: '•',
|
bulletListMarker: '-',
|
||||||
}).use(attrs).use(anchor).use(implicitFigures).use(emoji); // Add attrs plugin for adding attributes to elements
|
}).use(attrs).use(anchor).use(implicitFigures).use(emoji); // Add attrs plugin for adding attributes to elements
|
||||||
|
|
||||||
|
|
||||||
@ -208,7 +212,8 @@ export default {
|
|||||||
function executeCode(id) {
|
function executeCode(id) {
|
||||||
const codeElement = document.getElementById('code_' + id);
|
const codeElement = document.getElementById('code_' + id);
|
||||||
const codeExecElement = document.getElementById('code_exec_' + id);
|
const codeExecElement = document.getElementById('code_exec_' + id);
|
||||||
codeExecElement.classList.remove('hidden');
|
const preExecElement = document.getElementById('pre_exec_' + id);
|
||||||
|
|
||||||
const code = codeElement.innerText
|
const code = codeElement.innerText
|
||||||
const json = JSON.stringify({ 'code': code })
|
const json = JSON.stringify({ 'code': code })
|
||||||
console.log(json)
|
console.log(json)
|
||||||
@ -223,6 +228,7 @@ export default {
|
|||||||
.then(jsonData => {
|
.then(jsonData => {
|
||||||
// Now you can work with the JSON data
|
// Now you can work with the JSON data
|
||||||
console.log(jsonData);
|
console.log(jsonData);
|
||||||
|
preExecElement.classList.remove('hidden');
|
||||||
codeExecElement.innerText=jsonData.output
|
codeExecElement.innerText=jsonData.output
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user