mirror of
https://github.com/nomic-ai/gpt4all-ui.git
synced 2024-09-16 14:32:40 +00:00
fixed c9dd6d2f-d83a-488b-9443-d4200c010851
This commit is contained in:
parent
5e3f5dbbf6
commit
34f0e78ea4
@ -10,11 +10,12 @@ description:
|
||||
"""
|
||||
|
||||
from fastapi import APIRouter, Request
|
||||
from pydantic import BaseModel
|
||||
import pkg_resources
|
||||
from lollms_webui import LOLLMSWebUI
|
||||
from ascii_colors import ASCIIColors
|
||||
from lollms.utilities import load_config, run_async
|
||||
from lollms.security import sanitize_path, forbid_remote_access
|
||||
from lollms.utilities import load_config, run_async, show_yes_no_dialog
|
||||
from lollms.security import sanitize_path, forbid_remote_access, check_access
|
||||
from pathlib import Path
|
||||
from typing import List
|
||||
import sys
|
||||
@ -28,7 +29,7 @@ router = APIRouter()
|
||||
|
||||
|
||||
@router.get("/get_versionID")
|
||||
async def get_lollms_webui_version():
|
||||
async def get_lollms_version():
|
||||
"""Get the version of the LoLLMs Web UI application."""
|
||||
# Return the version string
|
||||
return {"id":4}
|
||||
@ -39,9 +40,12 @@ async def get_lollms_webui_version():
|
||||
# Return the version string
|
||||
return lollmsElfServer.version
|
||||
|
||||
class Identification(BaseModel):
|
||||
client_id:str
|
||||
|
||||
@router.get("/restart_program")
|
||||
async def restart_program():
|
||||
@router.post("/restart_program")
|
||||
async def restart_program(data:Identification):
|
||||
check_access(lollmsElfServer, data.client_id)
|
||||
"""Restart the program."""
|
||||
forbid_remote_access(lollmsElfServer)
|
||||
if lollmsElfServer.config.headless_server_mode:
|
||||
@ -50,6 +54,10 @@ async def restart_program():
|
||||
if lollmsElfServer.config.host!="localhost" and lollmsElfServer.config.host!="127.0.0.1":
|
||||
return {"status":False,"error":"Restarting app is blocked when the server is exposed outside for very obvious reasons!"}
|
||||
|
||||
if lollmsElfServer.config.turn_on_setting_update_validation:
|
||||
if not show_yes_no_dialog("Validation","Reboot requested from client\nDo you validate rebooting the app?"):
|
||||
return {"status":False,"error":"User refused the execution!"}
|
||||
|
||||
lollmsElfServer.ShowBlockingMessage("Restarting program.\nPlease stand by...")
|
||||
# Stop the socketIO server
|
||||
run_async(lollmsElfServer.sio.shutdown)
|
||||
@ -68,8 +76,9 @@ async def restart_program():
|
||||
ASCIIColors.info("")
|
||||
lollmsElfServer.run_restart_script(lollmsElfServer.args)
|
||||
|
||||
@router.get("/update_software")
|
||||
async def update_software():
|
||||
@router.post("/update_software")
|
||||
async def update_software(data:Identification):
|
||||
check_access(lollmsElfServer, data.client_id)
|
||||
"""Update the software."""
|
||||
forbid_remote_access(lollmsElfServer)
|
||||
if lollmsElfServer.config.headless_server_mode:
|
||||
@ -77,7 +86,11 @@ async def update_software():
|
||||
|
||||
if lollmsElfServer.config.host!="localhost" and lollmsElfServer.config.host!="127.0.0.1":
|
||||
return {"status":False,"error":"Updating app is blocked when the server is exposed outside for very obvious reasons!"}
|
||||
|
||||
|
||||
if lollmsElfServer.config.turn_on_setting_update_validation:
|
||||
if not show_yes_no_dialog("Validation","App upgrade requested from client\nDo you validate rebooting the app?"):
|
||||
return {"status":False,"error":"User refused the execution!"}
|
||||
|
||||
# Display an informative message
|
||||
ASCIIColors.info("")
|
||||
ASCIIColors.info("")
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 813f8bd55b0d7bb62156a6d64dff5e219c5ea8c3
|
||||
Subproject commit ed4da43b8beb132e4463c538e66eb8edb16b7215
|
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">
|
||||
<title>LoLLMS WebUI - Welcome</title>
|
||||
<script type="module" crossorigin src="/assets/index-7e441524.js"></script>
|
||||
<link rel="stylesheet" href="/assets/index-a6b015cd.css">
|
||||
<script type="module" crossorigin src="/assets/index-59608853.js"></script>
|
||||
<link rel="stylesheet" href="/assets/index-91104afa.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
@ -331,7 +331,7 @@ export default {
|
||||
},
|
||||
restartProgram(event) {
|
||||
event.preventDefault();
|
||||
this.$store.state.api_get_req('restart_program')
|
||||
this.$store.state.api_post_req('restart_program', this.$store.state.client_id)
|
||||
this.rebooting_audio.play()
|
||||
this.$store.state.toast.showToast("Rebooting the app. Please wait...", 410, false)
|
||||
//this.$store.state.toast.showToast("Rebooting the app. Please wait...", 50, true);
|
||||
|
@ -52,6 +52,7 @@ export const store = createStore({
|
||||
news:null,
|
||||
messageBox:null,
|
||||
api_get_req:null,
|
||||
api_post_req:null,
|
||||
startSpeechRecognition:null,
|
||||
ready:false,
|
||||
loading_infos: "",
|
||||
@ -635,6 +636,22 @@ async function api_get_req(endpoint) {
|
||||
}
|
||||
}
|
||||
|
||||
async function api_post_req(endpoint, client_id) {
|
||||
try {
|
||||
const res = await axios.post("/" + endpoint, {client_id: client_id});
|
||||
|
||||
if (res) {
|
||||
|
||||
return res.data
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error.message, 'api_post_req - settings')
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async function refreshHardwareUsage(store) {
|
||||
await store.dispatch('refreshDiskUsage');
|
||||
await store.dispatch('refreshRamUsage');
|
||||
@ -646,6 +663,8 @@ app.mixin({
|
||||
async created() {
|
||||
if (!actionsExecuted) {
|
||||
this.$store.state.api_get_req = api_get_req
|
||||
this.$store.state.api_post_req = api_post_req
|
||||
|
||||
actionsExecuted = true;
|
||||
console.log("Calling")
|
||||
|
||||
|
@ -41,14 +41,14 @@
|
||||
<button
|
||||
title="Restart program"
|
||||
class="text-2xl hover:text-secondary duration-75 active:scale-90"
|
||||
@click="api_get_req('restart_program').then((res)=>{if(res.status){this.$store.state.toast.showToast('Success!', 4, true)}else{this.$store.state.toast.showToast(['failed!'], 4, false)}})"
|
||||
@click="api_post_req('restart_program').then((res)=>{if(res.status){this.$store.state.toast.showToast('Success!', 4, true)}else{this.$store.state.toast.showToast(['failed!'], 4, false)}})"
|
||||
>
|
||||
<i data-feather="refresh-ccw"></i>
|
||||
</button>
|
||||
<button
|
||||
title="Upgrade program "
|
||||
class="text-2xl hover:text-secondary duration-75 active:scale-90"
|
||||
@click="api_get_req('update_software').then((res)=>{if(res.status){this.$store.state.toast.showToast('Success!', 4, true)}else{this.$store.state.toast.showToast('Success!', 4, true)}})"
|
||||
@click="api_post_req('update_software').then((res)=>{if(res.status){this.$store.state.toast.showToast('Success!', 4, true)}else{this.$store.state.toast.showToast('Success!', 4, true)}})"
|
||||
>
|
||||
<i data-feather="arrow-up-circle"></i>
|
||||
|
||||
@ -3429,7 +3429,7 @@ export default {
|
||||
},
|
||||
async update_software() {
|
||||
console.log("Posting")
|
||||
const res = await this.api_get_req('update_software')
|
||||
const res = await this.api_post_req('update_software')
|
||||
console.log("Posting done")
|
||||
if(res.status){
|
||||
this.$store.state.toast.showToast("Success!", 4, true)
|
||||
@ -3441,7 +3441,7 @@ export default {
|
||||
},
|
||||
async restart_software() {
|
||||
console.log("Posting")
|
||||
const res = await this.api_get_req('restart_program')
|
||||
const res = await this.api_post_req('restart_program')
|
||||
console.log("Posting done")
|
||||
if(res.status){
|
||||
this.$store.state.toast.showToast("Success!", 4, true)
|
||||
@ -4601,6 +4601,22 @@ export default {
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
async api_post_req(endpoint) {
|
||||
try {
|
||||
const res = await axios.post("/" + endpoint, {client_id: this.$store.state.client_id});
|
||||
|
||||
if (res) {
|
||||
|
||||
return res.data
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error.message, 'api_post_req - settings')
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
closeToast() {
|
||||
this.showToast = false
|
||||
|
Loading…
Reference in New Issue
Block a user