diff --git a/scripts/macos/macos_run.sh b/scripts/macos/macos_run.sh index 46c9069e..32c7d879 100644 --- a/scripts/macos/macos_run.sh +++ b/scripts/macos/macos_run.sh @@ -25,7 +25,7 @@ miniconda_folder="./installer_files" TMP="./installer_files/temp" if [ -e "$miniconda_folder" ]; then - INSTALL_ENV_DIR="./installer_files/lollms_env" + INSTALL_ENV_DIR="./installer_files/miniconda3/envs/lollms" MINICONDA_DIR="./installer_files/miniconda3" MINICONDA_CMD="$MINICONDA_DIR/bin/activate" if [ ! -f "$MINICONDA_DIR/bin/activate" ]; then diff --git a/utilities/execution_engines/graphviz_execution_engine.py b/utilities/execution_engines/graphviz_execution_engine.py index 168d7aaf..8c22c86a 100644 --- a/utilities/execution_engines/graphviz_execution_engine.py +++ b/utilities/execution_engines/graphviz_execution_engine.py @@ -17,7 +17,7 @@ from lollms.utilities import discussion_path_2_url lollmsElfServer:LOLLMSWebUI = LOLLMSWebUI.get_instance() -def build_graphviz_output(code, ifram_name="unnamed"): +def build_graphviz_output(code, ifram_name=None): """ This function creates an HTML5 iframe with the given HTML content and iframe name. @@ -29,43 +29,75 @@ def build_graphviz_output(code, ifram_name="unnamed"): str: The HTML string for the iframe. """ # Start the timer. - start_time = time.time() - rendered = "\n".join([ - '
', - f'', - '
' - ] - ) + start_time = time.time() + if ifram_name!=None: + rendered = "\n".join([ + '
', + f'', + '
' + ] + ) + else: + rendered = "\n".join([ + '
', + '', + '
', + '', + '', + '
', + '
', + '
' + ] + ) + execution_time = time.time() - start_time return {"output": rendered, "execution_time": execution_time} diff --git a/utilities/execution_engines/svg_execution_engine.py b/utilities/execution_engines/svg_execution_engine.py new file mode 100644 index 00000000..401007f2 --- /dev/null +++ b/utilities/execution_engines/svg_execution_engine.py @@ -0,0 +1,107 @@ +""" +project: lollms_webui +file: shell_execution_engine.py +author: ParisNeo +description: + This is a utility for executing python code + +""" +from lollms_webui import LOLLMSWebUI +from ascii_colors import get_trace_exception, trace_exception +import time +import subprocess +import json +from lollms.client_session import Client +from lollms.utilities import discussion_path_2_url + + +lollmsElfServer:LOLLMSWebUI = LOLLMSWebUI.get_instance() + +def build_svg_output(code, ifram_name="unnamed"): + """ + This function creates an HTML5 iframe with the given HTML content and iframe name. + + Args: + code (str): The svg code + ifram_name (str, optional): The name of the iframe. Defaults to "unnamed". + + Returns: + str: The HTML string for the iframe. + """ + # Start the timer. + start_time = time.time() + rendered = "\n".join([ + '
', + f'', + '
' + ] + ) + execution_time = time.time() - start_time + return {"output": rendered, "execution_time": execution_time} + + + + + +def execute_svg(code, client:Client, message_id, build_file=False): + if build_file: + # Start the timer. + start_time = time.time() + if not "http" in lollmsElfServer.config.host and not "https" in lollmsElfServer.config.host: + host = "http://"+lollmsElfServer.config.host + else: + host = lollmsElfServer.config.host + + # Create a temporary file. + root_folder = client.discussion.discussion_folder + root_folder.mkdir(parents=True,exist_ok=True) + tmp_file = root_folder/f"ai_code_{message_id}.html" + with open(tmp_file,"w",encoding="utf8") as f: + f.write(build_svg_output(code)["output"]) + link = f"{host}:{lollmsElfServer.config.port}/{discussion_path_2_url(tmp_file)}" + # Stop the timer. + execution_time = time.time() - start_time + output_json = {"output": f'Page built successfully
Press here to view the page', "execution_time": execution_time} + return output_json + else: + return build_svg_output(code)