mirror of
https://github.com/ParisNeo/lollms-webui.git
synced 2024-12-18 12:16:22 +00:00
Added lilypond execution engine
This commit is contained in:
parent
cd07e0307c
commit
c7341b32bd
@ -51,6 +51,8 @@ from utilities.execution_engines.mermaid_execution_engine import execute_mermaid
|
||||
from utilities.execution_engines.graphviz_execution_engine import execute_graphviz
|
||||
from utilities.execution_engines.svg_execution_engine import execute_svg
|
||||
|
||||
from utilities.execution_engines.lilypond_execution_engine import execute_lilypond
|
||||
|
||||
|
||||
import os
|
||||
from fastapi import FastAPI, UploadFile, File
|
||||
@ -115,6 +117,11 @@ async def execute_code(request: CodeRequest):
|
||||
ASCIIColors.info("Executing svg code:")
|
||||
ASCIIColors.yellow(code)
|
||||
return execute_svg(sanitize_svg(code), client, message_id)
|
||||
if language=="lilypond":
|
||||
ASCIIColors.info("Executing svg code:")
|
||||
ASCIIColors.yellow(code)
|
||||
return execute_lilypond(code, client, message_id)
|
||||
|
||||
if language=="javascript":
|
||||
ASCIIColors.info("Executing javascript code:")
|
||||
ASCIIColors.yellow(code)
|
||||
|
@ -38,17 +38,6 @@ def validate_file_path(path):
|
||||
print(f"Path validation error: {str(e)}")
|
||||
return False
|
||||
|
||||
from utilities.execution_engines.python_execution_engine import execute_python
|
||||
from utilities.execution_engines.latex_execution_engine import execute_latex
|
||||
from utilities.execution_engines.shell_execution_engine import execute_bash
|
||||
from utilities.execution_engines.javascript_execution_engine import execute_javascript
|
||||
from utilities.execution_engines.html_execution_engine import execute_html
|
||||
|
||||
from utilities.execution_engines.mermaid_execution_engine import execute_mermaid
|
||||
from utilities.execution_engines.graphviz_execution_engine import execute_graphviz
|
||||
from utilities.execution_engines.svg_execution_engine import execute_svg
|
||||
|
||||
|
||||
|
||||
|
||||
# ----------------------- Defining router and main class ------------------------------
|
||||
|
85
utilities/execution_engines/lilypond_execution_engine.py
Normal file
85
utilities/execution_engines/lilypond_execution_engine.py
Normal file
@ -0,0 +1,85 @@
|
||||
"""
|
||||
project: lollms_webui
|
||||
file: lilypond_execution_engine.py
|
||||
author: LilyPond integration
|
||||
description:
|
||||
This is a utility for executing LilyPond code in LOLLMS
|
||||
"""
|
||||
|
||||
import pipmaster as pm
|
||||
from lollms_webui import LOLLMSWebUI
|
||||
from ascii_colors import trace_exception
|
||||
import subprocess
|
||||
import time
|
||||
from pathlib import Path
|
||||
from lollms.client_session import Client
|
||||
from lollms.utilities import discussion_path_to_url, show_yes_no_dialog
|
||||
import shutil
|
||||
lollmsElfServer:LOLLMSWebUI = LOLLMSWebUI.get_instance()
|
||||
|
||||
def check_and_install_lilypond():
|
||||
"""Check if LilyPond is installed and install it if needed"""
|
||||
if not pm.is_installed("lilypond"):
|
||||
if not show_yes_no_dialog("Installation","LilyPond is not installed. Do you want to install it?"):
|
||||
return {"status":False,"error":"User refused LilyPond installation!"}
|
||||
try:
|
||||
pm.install("lilypond")
|
||||
return {"status":True}
|
||||
except Exception as ex:
|
||||
return {"status":False,"error":f"Failed to install LilyPond: {str(ex)}"}
|
||||
return {"status":True}
|
||||
|
||||
def execute_lilypond(code, client:Client, message_id):
|
||||
"""Execute LilyPond code and return the result"""
|
||||
try:
|
||||
# Check LilyPond installation
|
||||
check_result = check_and_install_lilypond()
|
||||
if not check_result["status"]:
|
||||
return {"output": check_result["error"], "execution_time": 0}
|
||||
|
||||
# Start timer
|
||||
start_time = time.time()
|
||||
|
||||
# Import LilyPond after installation check
|
||||
import lilypond
|
||||
|
||||
# Create work directory in discussion folder
|
||||
root_folder = client.discussion.discussion_folder
|
||||
root_folder.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# Create LilyPond file
|
||||
ly_file = root_folder/f"score_{message_id}.ly"
|
||||
ly_file.write_text(code)
|
||||
|
||||
# Get the PDF and MIDI outputs
|
||||
pdf_file = ly_file.with_suffix('.pdf')
|
||||
midi_file = ly_file.with_suffix('.mid')
|
||||
|
||||
# Compile the file
|
||||
subprocess.run([lilypond.executable(), str(ly_file)], check=True, cwd=root_folder)
|
||||
|
||||
# Create links to files
|
||||
if not "http" in lollmsElfServer.config.host and not "https" in lollmsElfServer.config.host:
|
||||
host = "http://"+lollmsElfServer.config.host
|
||||
else:
|
||||
host = lollmsElfServer.config.host
|
||||
|
||||
pdf_link = f"{host}:{lollmsElfServer.config.port}{discussion_path_to_url(pdf_file)}"
|
||||
midi_link = f"{host}:{lollmsElfServer.config.port}{discussion_path_to_url(midi_file)}"
|
||||
|
||||
# Create output HTML
|
||||
output = f"""
|
||||
<div>
|
||||
<h3>LilyPond Output:</h3>
|
||||
<p><a href="{pdf_link}" target="_blank">View PDF Score</a></p>
|
||||
<p><a href="{midi_link}" target="_blank">Download MIDI</a></p>
|
||||
<embed src="{pdf_link}" type="application/pdf" width="100%" height="600px">
|
||||
</div>
|
||||
"""
|
||||
|
||||
execution_time = time.time() - start_time
|
||||
return {"output": output, "execution_time": execution_time}
|
||||
|
||||
except Exception as ex:
|
||||
trace = trace_exception(ex)
|
||||
return {"output": f"Error executing LilyPond code:\n{trace}", "execution_time": 0}
|
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
4
web/dist/index.html
vendored
@ -6,8 +6,8 @@
|
||||
<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js"></script>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>LoLLMS WebUI</title>
|
||||
<script type="module" crossorigin src="/assets/index-CX5jATIW.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-Dk2jggHn.css">
|
||||
<script type="module" crossorigin src="/assets/index-CSHYN0YB.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-CZl152Xi.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
@ -20,7 +20,7 @@
|
||||
>
|
||||
<i data-feather="copy"></i>
|
||||
</button>
|
||||
<button v-if="['function', 'python', 'sh', 'shell', 'bash', 'cmd', 'powershell', 'latex', 'mermaid', 'graphviz', 'dot', 'javascript', 'html', 'html5', 'svg'].includes(language)" ref="btn_code_exec" @click="executeCode" title="execute"
|
||||
<button v-if="['function', 'python', 'sh', 'shell', 'bash', 'cmd', 'powershell', 'latex', 'mermaid', 'graphviz', 'dot', 'javascript', 'html', 'html5', 'svg', 'lilypond'].includes(language)" ref="btn_code_exec" @click="executeCode" title="execute"
|
||||
class="px-2 py-1 mr-2 mb-2 text-left text-sm font-medium rounded-lg hover:bg-primary dark:hover:bg-primary text-white transition-colors duration-200"
|
||||
:class="isExecuting?'bg-green-500':''">
|
||||
<i data-feather="play-circle"></i>
|
||||
|
@ -1292,7 +1292,38 @@ export default {
|
||||
"Quantum computers can perform calculations in minutes that would take classical computers thousands of years.",
|
||||
"LoLLMs supports multimodal interactions, allowing users to work with both text and images.",
|
||||
"The name Saïph in Arabic (سيف) means 'sword', symbolizing cutting-edge AI technology.",
|
||||
'<div class="flex items-center justify-center"><iframe width="560" height="315" src="https://www.youtube.com/embed/7pSXGj0dSzE?si=Ov0Y4F2mCRSB61xc" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>'
|
||||
'<div class="flex items-center justify-center"><iframe width="560" height="315" src="https://www.youtube.com/embed/7pSXGj0dSzE?si=Ov0Y4F2mCRSB61xc" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>',
|
||||
"LoLLMs' version naming often contains clever easter eggs and references to AI advancements.",
|
||||
"The 'Strawberry' version of LoLLMs was a playful nod to ChatGPT's internal codename for one of its versions.",
|
||||
"The 'Saïph' version name was an intentional reference to Orion, anticipating OpenAI's rumored AGI-capable model codenamed 'Orion'.",
|
||||
"LoLLMs' evolution can be traced through its version names: Warp, Starship, Robot, Brainwave, Strawberry, and Saïph.",
|
||||
"Each LoLLMs version name reflects either technological advancement or pays homage to significant developments in AI.",
|
||||
"'Warp' and 'Starship' versions symbolized the quantum leap in AI capabilities and speed improvements.",
|
||||
"'Robot' represented the system's growing autonomy and ability to perform complex tasks.",
|
||||
"'Brainwave' highlighted the neural network aspects and cognitive capabilities of the system.",
|
||||
"LoLLMs' version naming shows ParisNeo's keen awareness of industry trends and playful approach to development.",
|
||||
// New facts to add to the interestingFacts array
|
||||
"LoLLMs can generate and visualize mathematical equations using LaTeX, making it a powerful tool for scientific documentation.",
|
||||
"The system's multimodel capabilities allow it to analyze medical images, architectural blueprints, and technical diagrams.",
|
||||
"LoLLMs includes a unique feature called 'personality system' that allows it to adapt its communication style and expertise.",
|
||||
"Did you know? LoLLMs can process and generate music notation using ABC notation or LilyPond formats.",
|
||||
"LoLLMs supports over 40 different AI models, making it one of the most versatile open-source AI platforms.",
|
||||
"The system can generate realistic 3D scenes descriptions that can be rendered using tools like Blender.",
|
||||
"LoLLMs features a unique 'model fusion' capability, combining strengths of different AI models for better results.",
|
||||
"The platform includes specialized modules for scientific computing, allowing it to solve complex mathematical problems.",
|
||||
"LoLLMs can analyze and generate code in over 20 programming languages, including rare ones like COBOL and Fortran.",
|
||||
"The system includes advanced prompt engineering tools, helping users get better results from AI models.",
|
||||
"LoLLMs can generate and interpret QR codes, making it useful for creating interactive marketing materials.",
|
||||
"The platform supports real-time voice interaction through its advanced speech-to-text and text-to-speech capabilities.",
|
||||
"LoLLMs can analyze satellite imagery for environmental monitoring and urban planning applications.",
|
||||
"The system includes specialized modules for protein folding prediction and molecular visualization.",
|
||||
"LoLLMs features a built-in 'ethical AI' framework that ensures responsible and bias-aware AI interactions.",
|
||||
"The platform can generate realistic synthetic data while preserving privacy and maintaining statistical properties.",
|
||||
"LoLLMs includes advanced natural language processing capabilities in over 100 languages.",
|
||||
"The system can perform sentiment analysis on social media trends and customer feedback in real-time.",
|
||||
"LoLLMs features a unique 'time-aware' context system that understands and reasons about temporal relationships.",
|
||||
"The platform includes specialized tools for quantum computing simulation and algorithm development."
|
||||
|
||||
],
|
||||
randomFact: "",
|
||||
showPlaceholderModal: false,
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 9d7182f972199b99022372937486ae771774f910
|
||||
Subproject commit a7406c349335dfa982c1f3c751aca16852c06c77
|
@ -1 +1 @@
|
||||
Subproject commit c758105281caee7c41a5c4d1258bfc77e1191467
|
||||
Subproject commit 9b14edd78d50493e037ae29e814fee038b4a1dec
|
@ -1 +1 @@
|
||||
Subproject commit 4b299818e120a6b76d119905d965bb30abc39131
|
||||
Subproject commit 5c19109f1bd3ac9c319c0b729e2434b1ca6b0732
|
Loading…
Reference in New Issue
Block a user