mirror of
https://github.com/ParisNeo/lollms-webui.git
synced 2024-12-18 20:17:50 +00:00
upgraded
This commit is contained in:
parent
0766c5f8a0
commit
448d90b25e
@ -1 +1 @@
|
|||||||
Subproject commit 310eafa0abd54e1e9cd5c5c49a3b26a312dd95cb
|
Subproject commit fb402a5d3d043efbecd7199ea45927d6ad37af6c
|
@ -20,10 +20,10 @@ from lollms.paths import LollmsPaths
|
|||||||
from lollms.helpers import ASCIIColors, trace_exception
|
from lollms.helpers import ASCIIColors, trace_exception
|
||||||
from lollms.com import NotificationType, NotificationDisplayType, LoLLMsCom
|
from lollms.com import NotificationType, NotificationDisplayType, LoLLMsCom
|
||||||
from lollms.app import LollmsApplication
|
from lollms.app import LollmsApplication
|
||||||
from lollms.utilities import File64BitsManager, PromptReshaper, PackageManager, find_first_available_file_index
|
from lollms.utilities import File64BitsManager, PromptReshaper, PackageManager, find_first_available_file_index, run_async
|
||||||
import git
|
import git
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import os
|
||||||
try:
|
try:
|
||||||
from lollms.media import WebcamImageSender, AudioRecorder
|
from lollms.media import WebcamImageSender, AudioRecorder
|
||||||
Media_on=True
|
Media_on=True
|
||||||
@ -316,7 +316,24 @@ class LOLLMSWebUI(LOLLMSElfServer):
|
|||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
|
def run_restart_script(self, args):
|
||||||
|
restart_script = Path(__file__).parent/"restart_script.py"
|
||||||
|
|
||||||
|
# Convert Namespace object to a dictionary
|
||||||
|
args_dict = vars(args)
|
||||||
|
|
||||||
|
# Filter out any key-value pairs where the value is None
|
||||||
|
valid_args = {key: value for key, value in args_dict.items() if value is not None}
|
||||||
|
|
||||||
|
# Save the arguments to a temporary file
|
||||||
|
temp_file = Path(__file__).parent/"temp_args.txt"
|
||||||
|
with open(temp_file, "w") as file:
|
||||||
|
# Convert the valid_args dictionary to a string in the format "key1 value1 key2 value2 ..."
|
||||||
|
arg_string = " ".join([f"--{key} {value}" for key, value in valid_args.items()])
|
||||||
|
file.write(arg_string)
|
||||||
|
|
||||||
|
os.system(f"python {restart_script}")
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
def audio_callback(self, output):
|
def audio_callback(self, output):
|
||||||
if self.summoned:
|
if self.summoned:
|
||||||
@ -942,9 +959,10 @@ class LOLLMSWebUI(LOLLMSElfServer):
|
|||||||
duration:int=4,
|
duration:int=4,
|
||||||
client_id=None,
|
client_id=None,
|
||||||
display_type:NotificationDisplayType=NotificationDisplayType.TOAST,
|
display_type:NotificationDisplayType=NotificationDisplayType.TOAST,
|
||||||
verbose=True
|
verbose=True,
|
||||||
):
|
):
|
||||||
asyncio.run(
|
|
||||||
|
run_async(
|
||||||
self.socketio.emit('notification', {
|
self.socketio.emit('notification', {
|
||||||
'content': content,# self.connections[client_id]["generated_text"],
|
'content': content,# self.connections[client_id]["generated_text"],
|
||||||
'notification_type': notification_type.value,
|
'notification_type': notification_type.value,
|
||||||
@ -992,7 +1010,7 @@ class LOLLMSWebUI(LOLLMSElfServer):
|
|||||||
model = self.config["model_name"],
|
model = self.config["model_name"],
|
||||||
personality = self.config["personalities"][self.config["active_personality_id"]],
|
personality = self.config["personalities"][self.config["active_personality_id"]],
|
||||||
) # first the content is empty, but we'll fill it at the end
|
) # first the content is empty, but we'll fill it at the end
|
||||||
asyncio.run(
|
run_async(
|
||||||
self.socketio.emit('new_message',
|
self.socketio.emit('new_message',
|
||||||
{
|
{
|
||||||
"sender": sender,
|
"sender": sender,
|
||||||
@ -1026,7 +1044,7 @@ class LOLLMSWebUI(LOLLMSElfServer):
|
|||||||
self.connections[client_id]["current_discussion"].current_message.finished_generating_at=datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
self.connections[client_id]["current_discussion"].current_message.finished_generating_at=datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||||
mtdt = json.dumps(metadata, indent=4) if metadata is not None and type(metadata)== list else metadata
|
mtdt = json.dumps(metadata, indent=4) if metadata is not None and type(metadata)== list else metadata
|
||||||
if self.nb_received_tokens==1:
|
if self.nb_received_tokens==1:
|
||||||
asyncio.run(
|
run_async(
|
||||||
self.socketio.emit('update_message', {
|
self.socketio.emit('update_message', {
|
||||||
"sender": self.personality.name,
|
"sender": self.personality.name,
|
||||||
'id':self.connections[client_id]["current_discussion"].current_message.id,
|
'id':self.connections[client_id]["current_discussion"].current_message.id,
|
||||||
@ -1041,7 +1059,7 @@ class LOLLMSWebUI(LOLLMSElfServer):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
asyncio.run(
|
run_async(
|
||||||
self.socketio.emit('update_message', {
|
self.socketio.emit('update_message', {
|
||||||
"sender": self.personality.name,
|
"sender": self.personality.name,
|
||||||
'id':self.connections[client_id]["current_discussion"].current_message.id,
|
'id':self.connections[client_id]["current_discussion"].current_message.id,
|
||||||
@ -1067,7 +1085,7 @@ class LOLLMSWebUI(LOLLMSElfServer):
|
|||||||
self.connections[client_id]["generated_text"]=self.connections[client_id]["generated_text"].split("!@>")[0]
|
self.connections[client_id]["generated_text"]=self.connections[client_id]["generated_text"].split("!@>")[0]
|
||||||
# Send final message
|
# Send final message
|
||||||
self.connections[client_id]["current_discussion"].current_message.finished_generating_at=datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
self.connections[client_id]["current_discussion"].current_message.finished_generating_at=datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||||
asyncio.run(
|
run_async(
|
||||||
self.socketio.emit('close_message', {
|
self.socketio.emit('close_message', {
|
||||||
"sender": self.personality.name,
|
"sender": self.personality.name,
|
||||||
"id": self.connections[client_id]["current_discussion"].current_message.id,
|
"id": self.connections[client_id]["current_discussion"].current_message.id,
|
||||||
@ -1125,7 +1143,7 @@ class LOLLMSWebUI(LOLLMSElfServer):
|
|||||||
if message_type == MSG_TYPE.MSG_TYPE_NEW_MESSAGE:
|
if message_type == MSG_TYPE.MSG_TYPE_NEW_MESSAGE:
|
||||||
self.nb_received_tokens = 0
|
self.nb_received_tokens = 0
|
||||||
self.start_time = datetime.now()
|
self.start_time = datetime.now()
|
||||||
asyncio.run(
|
run_async(
|
||||||
self.new_message(
|
self.new_message(
|
||||||
client_id,
|
client_id,
|
||||||
self.personality.name if personality is None else personality.name,
|
self.personality.name if personality is None else personality.name,
|
||||||
@ -1404,7 +1422,7 @@ class LOLLMSWebUI(LOLLMSElfServer):
|
|||||||
if ttl is None or ttl=="" or ttl=="untitled":
|
if ttl is None or ttl=="" or ttl=="untitled":
|
||||||
title = self.make_discussion_title(d, client_id=client_id)
|
title = self.make_discussion_title(d, client_id=client_id)
|
||||||
d.rename(title)
|
d.rename(title)
|
||||||
asyncio.run(
|
run_async(
|
||||||
self.socketio.emit('disucssion_renamed',{
|
self.socketio.emit('disucssion_renamed',{
|
||||||
'status': True,
|
'status': True,
|
||||||
'discussion_id':d.discussion_id,
|
'discussion_id':d.discussion_id,
|
||||||
|
33
new_app.py
33
new_app.py
@ -12,6 +12,7 @@ from fastapi.responses import HTMLResponse
|
|||||||
from lollms.app import LollmsApplication
|
from lollms.app import LollmsApplication
|
||||||
from lollms.paths import LollmsPaths
|
from lollms.paths import LollmsPaths
|
||||||
from lollms.main_config import LOLLMSConfig
|
from lollms.main_config import LOLLMSConfig
|
||||||
|
from lollms.utilities import trace_exception
|
||||||
from lollms_webui import LOLLMSWebUI
|
from lollms_webui import LOLLMSWebUI
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from ascii_colors import ASCIIColors
|
from ascii_colors import ASCIIColors
|
||||||
@ -19,6 +20,7 @@ import socketio
|
|||||||
import uvicorn
|
import uvicorn
|
||||||
import argparse
|
import argparse
|
||||||
from socketio import ASGIApp
|
from socketio import ASGIApp
|
||||||
|
import webbrowser
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
|
|
||||||
@ -57,7 +59,7 @@ if __name__ == "__main__":
|
|||||||
config.port=args.port
|
config.port=args.port
|
||||||
|
|
||||||
LOLLMSWebUI.build_instance(config=config, lollms_paths=lollms_paths, socketio=sio)
|
LOLLMSWebUI.build_instance(config=config, lollms_paths=lollms_paths, socketio=sio)
|
||||||
lollmsElfServer = LOLLMSWebUI.get_instance()
|
lollmsElfServer:LOLLMSWebUI = LOLLMSWebUI.get_instance()
|
||||||
# Import all endpoints
|
# Import all endpoints
|
||||||
from lollms.server.endpoints.lollms_binding_files_server import router as lollms_binding_files_server_router
|
from lollms.server.endpoints.lollms_binding_files_server import router as lollms_binding_files_server_router
|
||||||
from lollms.server.endpoints.lollms_infos import router as lollms_infos_router
|
from lollms.server.endpoints.lollms_infos import router as lollms_infos_router
|
||||||
@ -108,4 +110,33 @@ if __name__ == "__main__":
|
|||||||
app = ASGIApp(socketio_server=sio, other_asgi_app=app)
|
app = ASGIApp(socketio_server=sio, other_asgi_app=app)
|
||||||
|
|
||||||
|
|
||||||
|
# if autoshow
|
||||||
|
if config.auto_show_browser:
|
||||||
|
if config['host']=="0.0.0.0":
|
||||||
|
#webbrowser.open(f"http://localhost:{config['port']}")
|
||||||
|
webbrowser.open(f"http://localhost:{6523}") # needed for debug (to be removed in production)
|
||||||
|
else:
|
||||||
|
#webbrowser.open(f"http://{config['host']}:{config['port']}")
|
||||||
|
webbrowser.open(f"http://{config['host']}:{6523}") # needed for debug (to be removed in production)
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
sio.reboot = False
|
||||||
uvicorn.run(app, host=config.host, port=6523)#config.port)
|
uvicorn.run(app, host=config.host, port=6523)#config.port)
|
||||||
|
if sio.reboot:
|
||||||
|
ASCIIColors.info("")
|
||||||
|
ASCIIColors.info("")
|
||||||
|
ASCIIColors.info("")
|
||||||
|
ASCIIColors.info(" ╔══════════════════════════════════════════════════╗")
|
||||||
|
ASCIIColors.info(" ║ Restarting backend ║")
|
||||||
|
ASCIIColors.info(" ╚══════════════════════════════════════════════════╝")
|
||||||
|
ASCIIColors.info("")
|
||||||
|
ASCIIColors.info("")
|
||||||
|
ASCIIColors.info("")
|
||||||
|
lollmsElfServer.run_restart_script(args)
|
||||||
|
|
||||||
|
except Exception as ex:
|
||||||
|
trace_exception(ex)
|
||||||
|
|
||||||
|
|
||||||
|
|
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 @@
|
|||||||
|
|
||||||
<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-46f88ef1.js"></script>
|
<script type="module" crossorigin src="/assets/index-db831b95.js"></script>
|
||||||
<link rel="stylesheet" href="/assets/index-27a6ba78.css">
|
<link rel="stylesheet" href="/assets/index-d5a593e6.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
|
@ -184,7 +184,7 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-2" v-for="item in vramUsage.gpus">
|
<div class="mb-2" v-for="item in vramUsage.gpus" :key="item">
|
||||||
<label class="flex items-center gap-1 ml-2 mb-2 text-sm font-medium text-gray-900 dark:text-white">
|
<label class="flex items-center gap-1 ml-2 mb-2 text-sm font-medium text-gray-900 dark:text-white">
|
||||||
<!-- GPU IMAGE -->
|
<!-- GPU IMAGE -->
|
||||||
<img :src="SVGGPU" width="25" height="25">
|
<img :src="SVGGPU" width="25" height="25">
|
||||||
@ -2438,8 +2438,6 @@ export default {
|
|||||||
},
|
},
|
||||||
async getVramUsage() {
|
async getVramUsage() {
|
||||||
const resp = await this.api_get_req("vram_usage")
|
const resp = await this.api_get_req("vram_usage")
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
async progressListener(response) {
|
async progressListener(response) {
|
||||||
// does not work Still freezes UI
|
// does not work Still freezes UI
|
||||||
@ -2642,7 +2640,7 @@ export default {
|
|||||||
this.is_loading_zoo = false
|
this.is_loading_zoo = false
|
||||||
})
|
})
|
||||||
self.updateModelsZoo()
|
self.updateModelsZoo()
|
||||||
api_get_req("get_model_status").then((res)=>{
|
this.api_get_req("get_model_status").then((res)=>{
|
||||||
this.$store.commit('setIsModelOk', res);
|
this.$store.commit('setIsModelOk', res);
|
||||||
})
|
})
|
||||||
}else{
|
}else{
|
||||||
@ -2892,7 +2890,7 @@ export default {
|
|||||||
this.update_binding(binding_object.binding.folder)
|
this.update_binding(binding_object.binding.folder)
|
||||||
this.binding_changed = true;
|
this.binding_changed = true;
|
||||||
}
|
}
|
||||||
api_get_req("get_model_status").then((res)=>{
|
this.api_get_req("get_model_status").then((res)=>{
|
||||||
this.$store.commit('setIsModelOk', res);
|
this.$store.commit('setIsModelOk', res);
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@ -3223,13 +3221,13 @@ export default {
|
|||||||
this.showAccordion = !this.showAccordion;
|
this.showAccordion = !this.showAccordion;
|
||||||
},
|
},
|
||||||
async update_setting(setting_name_val, setting_value_val, next) {
|
async update_setting(setting_name_val, setting_value_val, next) {
|
||||||
console.log("Updating setting", setting_name_val, ":", setting_value_val)
|
|
||||||
this.isLoading = true
|
this.isLoading = true
|
||||||
const obj = {
|
const obj = {
|
||||||
setting_name: setting_name_val,
|
setting_name: setting_name_val,
|
||||||
setting_value: setting_value_val
|
setting_value: setting_value_val
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("Updating setting", setting_name_val, ":", setting_value_val)
|
||||||
let res = await axios.post('/update_setting', obj)
|
let res = await axios.post('/update_setting', obj)
|
||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
|
Loading…
Reference in New Issue
Block a user