mirror of
https://github.com/ParisNeo/lollms-webui.git
synced 2025-01-31 08:25:24 +00:00
upgraded ui and endpoints
This commit is contained in:
parent
e88d0dd37f
commit
e981d5c49a
38
app.py
38
app.py
@ -149,29 +149,31 @@ if __name__ == "__main__":
|
||||
|
||||
lollmsElfServer.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
|
||||
if config.enable_lollms_service:
|
||||
#uvicorn.run(app, host=config.host, port=6523)
|
||||
def run_lollms_server():
|
||||
parts = config.lollms_base_url.split(":")
|
||||
uvicorn.run(app, host=":".join(parts[0:2]), port=int(parts[2]))
|
||||
# if config.enable_lollms_service:
|
||||
# ASCIIColors.yellow("Starting Lollms service")
|
||||
# #uvicorn.run(app, host=config.host, port=6523)
|
||||
# def run_lollms_server():
|
||||
# parts = config.lollms_base_url.split(":")
|
||||
# host = ":".join(parts[0:2])
|
||||
# port = int(parts[2])
|
||||
# uvicorn.run(app, host=host, port=port)
|
||||
# New thread
|
||||
thread = threading.Thread(target=run_lollms_server)
|
||||
# thread = threading.Thread(target=run_lollms_server)
|
||||
|
||||
# start thread
|
||||
thread.start()
|
||||
# thread.start()
|
||||
|
||||
# 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)
|
||||
|
||||
uvicorn.run(app, host=config.host, port=config.port)
|
||||
if sio.reboot:
|
||||
ASCIIColors.info("")
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 1b5e4be8b6b6433cd88a77c139136d59156539e7
|
||||
Subproject commit d100194b705b59d17064c746b6837cdc1304bf44
|
@ -21,6 +21,8 @@ from lollms.helpers import ASCIIColors, trace_exception
|
||||
from lollms.com import NotificationType, NotificationDisplayType, LoLLMsCom
|
||||
from lollms.app import LollmsApplication
|
||||
from lollms.utilities import File64BitsManager, PromptReshaper, PackageManager, find_first_available_file_index, run_async, is_asyncio_loop_running
|
||||
from lollms.generation import RECPTION_MANAGER, ROLE_CHANGE_DECISION, ROLE_CHANGE_OURTPUT
|
||||
|
||||
import git
|
||||
import asyncio
|
||||
import os
|
||||
@ -200,6 +202,7 @@ class LOLLMSWebUI(LOLLMSElfServer):
|
||||
"schedule_for_deletion":False,
|
||||
"continuing": False,
|
||||
"first_chunk": True,
|
||||
"reception_manager": RECPTION_MANAGER()
|
||||
}
|
||||
}
|
||||
if Media_on:
|
||||
@ -233,7 +236,8 @@ class LOLLMSWebUI(LOLLMSElfServer):
|
||||
"cancel_generation": False,
|
||||
"generation_thread": None,
|
||||
"processing":False,
|
||||
"schedule_for_deletion":False
|
||||
"schedule_for_deletion":False,
|
||||
"reception_manager":RECPTION_MANAGER()
|
||||
}
|
||||
await self.sio.emit('connected', to=sid)
|
||||
ASCIIColors.success(f'Client {sid} connected')
|
||||
@ -1192,6 +1196,7 @@ class LOLLMSWebUI(LOLLMSElfServer):
|
||||
self.close_message(client_id)
|
||||
|
||||
elif message_type == MSG_TYPE.MSG_TYPE_CHUNK:
|
||||
|
||||
if self.nb_received_tokens==0:
|
||||
self.start_time = datetime.now()
|
||||
dt =(datetime.now() - self.start_time).seconds
|
||||
@ -1202,6 +1207,7 @@ class LOLLMSWebUI(LOLLMSElfServer):
|
||||
sys.stdout = sys.__stdout__
|
||||
sys.stdout.flush()
|
||||
if chunk:
|
||||
|
||||
self.connections[client_id]["generated_text"] += chunk
|
||||
antiprompt = self.personality.detect_antiprompt(self.connections[client_id]["generated_text"])
|
||||
if antiprompt:
|
||||
|
@ -22,4 +22,4 @@ uvicorn
|
||||
python-multipart
|
||||
python-socketio
|
||||
python-socketio[client]
|
||||
python-socketio[asyncio_client]
|
||||
python-socketio[asyncio_client]
|
33
tests/unitary_tests/test_chat_interface.py
Normal file
33
tests/unitary_tests/test_chat_interface.py
Normal file
@ -0,0 +1,33 @@
|
||||
import requests
|
||||
import json
|
||||
|
||||
url = "http://localhost:1234/v1/chat/completions"
|
||||
|
||||
payload = {
|
||||
"messages": [
|
||||
{
|
||||
"role": "system",
|
||||
"content": "You are a research engineer specialized in the applications of AI in robotics."
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": "What are some popular AI frameworks for robotics?"
|
||||
}
|
||||
],
|
||||
"max_tokens": 100,
|
||||
"temperature": 0.5
|
||||
}
|
||||
|
||||
headers = {
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
|
||||
response = requests.post(url, data=json.dumps(payload), headers=headers)
|
||||
|
||||
if response.status_code == 200:
|
||||
data = response.json()
|
||||
print(data)
|
||||
completion = data["choices"][0]["message"]["content"]
|
||||
print(completion)
|
||||
else:
|
||||
print("Error:", response.status_code)
|
35
tests/unitary_tests/test_chat_interface_streaming.py
Normal file
35
tests/unitary_tests/test_chat_interface_streaming.py
Normal file
@ -0,0 +1,35 @@
|
||||
import requests
|
||||
import json
|
||||
|
||||
url = "http://localhost:1234/v1/chat/completions"
|
||||
|
||||
payload = {
|
||||
"messages": [
|
||||
{
|
||||
"role": "system",
|
||||
"content": "You are a research engineer specialized in the applications of AI in robotics."
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": "List a number of libraries I can use for robotics."
|
||||
}
|
||||
],
|
||||
"max_tokens": 100,
|
||||
"temperature": 0.5,
|
||||
"stream": True
|
||||
}
|
||||
|
||||
headers = {
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
|
||||
response = requests.post(url, data=json.dumps(payload), headers=headers, stream=True)
|
||||
|
||||
if response.status_code == 200:
|
||||
for response_chunk in response.iter_lines():
|
||||
if response_chunk:
|
||||
rc = response_chunk.decode()
|
||||
rc = json.loads(rc)
|
||||
print(rc["choices"][0]["delta"]["content"])
|
||||
else:
|
||||
print("Error:", response.status_code)
|
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-d3156257.js"></script>
|
||||
<link rel="stylesheet" href="/assets/index-a2ed5f05.css">
|
||||
<script type="module" crossorigin src="/assets/index-cbeaa67a.js"></script>
|
||||
<link rel="stylesheet" href="/assets/index-a692e1db.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
@ -253,37 +253,6 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="min-width: 200px;">
|
||||
<label for="db_path" class="text-sm font-bold" style="margin-right: 1rem;">Host:</label>
|
||||
</td>
|
||||
<td style="width: 100%;">
|
||||
<input
|
||||
type="text"
|
||||
id="host"
|
||||
required
|
||||
v-model="configFile.host"
|
||||
@change="settingsChanged=true"
|
||||
class="w-full w-full mt-1 px-2 py-1 border border-gray-300 rounded dark:bg-gray-600 dark:bg-gray-600"
|
||||
>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="min-width: 200px;">
|
||||
<label for="db_path" class="text-sm font-bold" style="margin-right: 1rem;">Port:</label>
|
||||
</td>
|
||||
<td style="width: 100%;">
|
||||
<input
|
||||
type="number"
|
||||
step="1"
|
||||
id="port"
|
||||
required
|
||||
v-model="configFile.port"
|
||||
@change="settingsChanged=true"
|
||||
class="w-full w-full mt-1 px-2 py-1 border border-gray-300 rounded dark:bg-gray-600 dark:bg-gray-600"
|
||||
>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="min-width: 200px;">
|
||||
<label for="db_path" class="text-sm font-bold" style="margin-right: 1rem;">Database path:</label>
|
||||
</td>
|
||||
@ -923,6 +892,41 @@
|
||||
</button>
|
||||
</div>
|
||||
<div :class="{ 'hidden': servers_conf_collapsed }" class="flex flex-col mb-2 px-3 pb-0">
|
||||
<Card title="Lollms service" :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="db_path" class="text-sm font-bold" style="margin-right: 1rem;">Host:</label>
|
||||
</td>
|
||||
<td style="width: 100%;">
|
||||
<input
|
||||
type="text"
|
||||
id="host"
|
||||
required
|
||||
v-model="configFile.host"
|
||||
@change="settingsChanged=true"
|
||||
class="w-full w-full mt-1 px-2 py-1 border border-gray-300 rounded dark:bg-gray-600 dark:bg-gray-600"
|
||||
>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="min-width: 200px;">
|
||||
<label for="db_path" class="text-sm font-bold" style="margin-right: 1rem;">Port:</label>
|
||||
</td>
|
||||
<td style="width: 100%;">
|
||||
<input
|
||||
type="number"
|
||||
step="1"
|
||||
id="port"
|
||||
required
|
||||
v-model="configFile.port"
|
||||
@change="settingsChanged=true"
|
||||
class="w-full w-full mt-1 px-2 py-1 border border-gray-300 rounded dark:bg-gray-600 dark:bg-gray-600"
|
||||
>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</Card>
|
||||
|
||||
<Card title="Stable diffusion service" :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">
|
||||
@ -954,7 +958,7 @@
|
||||
</td>
|
||||
<td>
|
||||
<div class="flex flex-row">
|
||||
<button class="hover:text-primary bg-green-200 rounded-lg p-4 m-4 w-full text-center items-center" @click="reinstallSDService">Reinstall sd service</button>
|
||||
<button class="hover:text-primary bg-green-200 rounded-lg p-4 m-4 w-full text-center items-center" @click="reinstallSDService">install sd service</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@ -1007,7 +1011,7 @@
|
||||
</td>
|
||||
<td>
|
||||
<div class="flex flex-row">
|
||||
<button class="hover:text-primary bg-green-200 rounded-lg p-4 m-4 w-full text-center items-center" @click="reinstallOLLAMAService">Reinstall olama service</button>
|
||||
<button class="hover:text-primary bg-green-200 rounded-lg p-4 m-4 w-full text-center items-center" @click="reinstallOLLAMAService">install olama service</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@ -1061,7 +1065,7 @@
|
||||
</td>
|
||||
<td>
|
||||
<div class="flex flex-row">
|
||||
<button class="hover:text-primary bg-green-200 rounded-lg p-4 m-4 w-full text-center items-center" @click="reinstallPetalsService">Reinstall petals service</button>
|
||||
<button class="hover:text-primary bg-green-200 rounded-lg p-4 m-4 w-full text-center items-center" @click="reinstallPetalsService">install petals service</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@ -1084,44 +1088,6 @@
|
||||
</tr>
|
||||
</table>
|
||||
</Card>
|
||||
<Card title="Lollms service" :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="enable_lollms_service" class="text-sm font-bold" style="margin-right: 1rem;">Enable lollms service:</label>
|
||||
</td>
|
||||
<td>
|
||||
<div class="flex flex-row">
|
||||
<input
|
||||
type="checkbox"
|
||||
id="enable_lollms_service"
|
||||
required
|
||||
v-model="configFile.enable_lollms_service"
|
||||
@change="settingsChanged=true"
|
||||
class="mt-1 px-2 py-1 border border-gray-300 rounded dark:bg-gray-600"
|
||||
>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="min-width: 200px;">
|
||||
<label for="lollms_base_url" class="text-sm font-bold" style="margin-right: 1rem;">lollms base url:</label>
|
||||
</td>
|
||||
<td>
|
||||
<div class="flex flex-row">
|
||||
<input
|
||||
type="text"
|
||||
id="lollms_base_url"
|
||||
required
|
||||
v-model="configFile.lollms_base_url"
|
||||
@change="settingsChanged=true"
|
||||
class="mt-1 px-2 py-1 border border-gray-300 rounded dark:bg-gray-600"
|
||||
>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</Card>
|
||||
<Card title="XTTS service" :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>
|
||||
@ -1147,7 +1113,7 @@
|
||||
</td>
|
||||
<td>
|
||||
<div class="flex flex-row">
|
||||
<button class="hover:text-primary bg-green-200 rounded-lg p-4 m-4 w-full text-center items-center" @click="reinstallAudioService">Reinstall xtts service</button>
|
||||
<button class="hover:text-primary bg-green-200 rounded-lg p-4 m-4 w-full text-center items-center" @click="reinstallAudioService">install xtts service</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit a15900a916c8a18bd327c74cac44a88e0c45d427
|
||||
Subproject commit 33ea04125e77faee82ea85632dc5a86af16fe45f
|
Loading…
x
Reference in New Issue
Block a user