enhanced UI

This commit is contained in:
Saifeddine ALOUI 2024-02-15 01:31:16 +01:00
parent f87df9e075
commit 594d1c8c8d
7 changed files with 252 additions and 188 deletions

View File

@ -1,8 +1,11 @@
# =================== Lord Of Large Language Multimodal Systems Configuration file ===========================
version: 58
version: 60
binding_name: null
model_name: null
turn_on_code_execution: True
turn_on_code_validation: False
headless_server_mode: False
allowed_origins: []

View File

@ -51,6 +51,22 @@ from utilities.execution_engines.graphviz_execution_engine import execute_graphv
router = APIRouter()
lollmsElfServer:LOLLMSWebUI = LOLLMSWebUI.get_instance()
def show_yes_no_dialog(title, text):
import tkinter as tk
from tkinter import messagebox
# Create a new Tkinter root window and hide it
root = tk.Tk()
root.withdraw()
# Show the dialog box
result = messagebox.askyesno(title, text)
# Destroy the root window
root.destroy()
return result
@router.post("/execute_code")
async def execute_code(request: Request):
"""
@ -59,12 +75,21 @@ async def execute_code(request: Request):
:param request: The HTTP request object.
:return: A JSON response with the status of the operation.
"""
if lollmsElfServer.config.headless_server_mode:
return {"status":False,"error":"Code execution is blocked when in headless mode for obvious security reasons!"}
if lollmsElfServer.config.host=="0.0.0.0":
return {"status":False,"error":"Code execution is blocked when the server is exposed outside for very obvipous reasons!"}
if not lollmsElfServer.config.turn_on_code_execution:
return {"status":False,"error":"Code execution is blocked by the configuration!"}
if lollmsElfServer.config.turn_on_code_validation:
if not show_yes_no_dialog("Validation","Do you validate the execution of the code?"):
return {"status":False,"error":"User refused the execution!"}
try:
data = (await request.json())
code = data["code"]

@ -1 +1 @@
Subproject commit 002102b5c9d7884074f501d95978e792f7534bd6
Subproject commit 25ce72fa3f7bebf9b951b764707983f87af6c0b3

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

4
web/dist/index.html vendored
View File

@ -6,8 +6,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>LoLLMS WebUI - Welcome</title>
<script type="module" crossorigin src="/assets/index-74b2874f.js"></script>
<link rel="stylesheet" href="/assets/index-6a014c04.css">
<script type="module" crossorigin src="/assets/index-a9ba20fe.js"></script>
<link rel="stylesheet" href="/assets/index-6a5a4887.css">
</head>
<body>
<div id="app"></div>

View File

@ -487,6 +487,42 @@
</tr>
</table>
</Card>
<Card title="Code execution" :is_subcard="true" class="pb-2 m-2">
<table class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500">
<tr>
<td style="min-width: 200px;">
<label for="turn_on_code_execution" class="text-sm font-bold" style="margin-right: 1rem;">turn on code execution:</label>
</td>
<td style="width: 100%;">
<input
type="checkbox"
id="turn_on_code_execution"
required
v-model="configFile.turn_on_code_execution"
@change="settingsChanged=true"
class="mt-1 px-2 py-1 border border-gray-300 rounded dark:bg-gray-600"
>
</td>
</tr>
<tr>
<td style="min-width: 200px;">
<label for="turn_on_code_validation" class="text-sm font-bold" style="margin-right: 1rem;">turn on code validation:</label>
</td>
<td style="width: 100%;">
<input
type="checkbox"
id="turn_on_code_validation"
required
v-model="configFile.turn_on_code_validation"
@change="settingsChanged=true"
class="mt-1 px-2 py-1 border border-gray-300 rounded dark:bg-gray-600"
>
</td>
</tr>
</table>
</Card>
<Card title="Data Vectorization" :is_subcard="true" class="pb-2 m-2">
<table class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500">
<tr>