This commit is contained in:
Saifeddine ALOUI 2024-01-03 01:41:01 +01:00
parent 488a55e56b
commit 6a95421253
16 changed files with 391 additions and 212 deletions

View File

@ -657,11 +657,16 @@ class LoLLMsAPI(LollmsApplication):
self.connections[client_id]["current_discussion"] = self.db.load_last_discussion()
if self.personality.welcome_message!="":
if self.config.force_output_language_to_be and self.config.force_output_language_to_be.lower().strip() !="english":
welcome_message = self.personality.fast_gen(f"!@>instruction: Translate the following text to {self.config.force_output_language_to_be.lower()}:\n{self.personality.welcome_message}\n!@>translation:")
else:
welcome_message = self.personality.welcome_message
message = self.connections[client_id]["current_discussion"].add_message(
message_type = MSG_TYPE.MSG_TYPE_FULL.value if self.personality.include_welcome_message_in_disucssion else MSG_TYPE.MSG_TYPE_FULL_INVISIBLE_TO_AI.value,
sender_type = SENDER_TYPES.SENDER_TYPES_AI.value,
sender = self.personality.name,
content = self.personality.welcome_message,
content = welcome_message,
metadata = None,
rank = 0,
parent_message_id = -1,
@ -1497,6 +1502,29 @@ class LoLLMsAPI(LollmsApplication):
documentation = ""
history = ""
# boosting information
if self.config.positive_boost:
positive_boost="\n!@>important information: "+self.config.positive_boost+"\n"
n_positive_boost = len(self.model.tokenize(positive_boost))
else:
positive_boost=""
n_positive_boost = 0
if self.config.negative_boost:
negative_boost="\n!@>important information: "+self.config.negative_boost+"\n"
n_negative_boost = len(self.model.tokenize(negative_boost))
else:
negative_boost=""
n_negative_boost = 0
if self.config.force_output_language_to_be:
force_language="\n!@>important information: Answer the user in this language :"+self.config.force_output_language_to_be+"\n"
n_force_language = len(self.model.tokenize(force_language))
else:
force_language=""
n_force_language = 0
if generation_type != "simple_question":
if self.personality.persona_data_vectorizer:
if documentation=="":
@ -1580,7 +1608,7 @@ class LoLLMsAPI(LollmsApplication):
# Calculate the total number of tokens between conditionning, documentation, and history
total_tokens = n_cond_tk + n_doc_tk + n_history_tk + n_user_description_tk
total_tokens = n_cond_tk + n_doc_tk + n_history_tk + n_user_description_tk + n_positive_boost + n_negative_boost + n_force_language
# Calculate the available space for the messages
available_space = self.config.ctx_size - n_tokens - total_tokens
@ -1650,11 +1678,12 @@ class LoLLMsAPI(LollmsApplication):
# Build the final discussion messages by detokenizing the full_message_list
discussion_messages = ""
for message_tokens in full_message_list:
for i in range(len(full_message_list)-1):
message_tokens = full_message_list[i]
discussion_messages += self.model.detokenize(message_tokens)
# Build the final prompt by concatenating the conditionning and discussion messages
prompt_data = conditionning + documentation + history + user_description + discussion_messages
prompt_data = conditionning + documentation + history + user_description + discussion_messages + positive_boost + negative_boost + force_language + self.model.detokenize(full_message_list[-1])
# Tokenize the prompt data
tokens = self.model.tokenize(prompt_data)

16
app.py
View File

@ -521,6 +521,9 @@ try:
self.add_endpoint(
"/install_xtts", "install_xtts", self.install_xtts, methods=["GET"]
)
self.add_endpoint(
"/install_sd", "install_sd", self.install_sd, methods=["GET"]
)
self.add_endpoint(
"/open_code_folder", "open_code_folder", self.open_code_folder, methods=["POST"]
@ -575,6 +578,7 @@ try:
server_address = request.host_url
return server_address
def install_xtts(self):
try:
self.ShowBlockingMessage("Installing xTTS api server\nPlease stand by")
@ -584,6 +588,18 @@ try:
except Exception as ex:
self.HideBlockingMessage()
return jsonify({"status":False, 'error':str(ex)})
def install_sd(self):
try:
self.ShowBlockingMessage("Installing SD api server\nPlease stand by")
from lollms.image_gen_modules.lollms_sd import install_sd
install_sd()
self.HideBlockingMessage()
return jsonify({"status":True})
except Exception as ex:
self.HideBlockingMessage()
return jsonify({"status":False, 'error':str(ex)})
def execute_python(self, code, discussion_id, message_id):
def spawn_process(code):
"""Executes Python code and returns the output as JSON."""

View File

@ -1,5 +1,5 @@
# =================== Lord Of Large Language Models Configuration file ===========================
version: 36
version: 39
binding_name: null
model_name: null
@ -56,6 +56,10 @@ auto_read: false
current_voice: null
current_language: en
# Image generation service
enable_sd_service: false
sd_base_url: http://127.0.0.1:7860
# Audio
media_on: false
audio_in_language: 'en-US'
@ -84,4 +88,9 @@ data_vectorization_make_persistance: false # If true, the data will be persistan
# Helpers
pdf_latex_path: null
pdf_latex_path: null
# boosting information
positive_boost: null
negative_boost: null
force_output_language_to_be: null

View File

@ -1,15 +0,0 @@
from fastapi import APIRouter
from lollms_webui import LoLLMSWebUI
router = APIRouter()
lollmsWebUI = LoLLMSWebUI.get_instance()
@router.get("/users")
def get_users():
# Your code here
pass
@router.post("/users")
def create_user():
# Your code here
pass

BIN
logo.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 420 KiB

@ -1 +1 @@
Subproject commit 402d01cfe09f8f68771ffdebad09097dd368d6cb
Subproject commit 3581e608e55dec29cc0926ca03065accb445d72c

View File

@ -44,6 +44,6 @@ if __name__ == "__main__":
config.port=args.port
LoLLMSWebUI.build_instance(config=config, lollms_paths=lollms_paths, socketio=sio)
from endpoints.lollms_infos import *
from lollms.server.endpoints.lollms_infos import *
uvicorn.run(app, host=config.host, port=config.port)

View File

@ -5,7 +5,7 @@
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + Vue</title>
<script type="module" crossorigin src="/assets/index-xU-eXePa.js"></script>
<script type="module" crossorigin src="/assets/index-Y2w-DnAU.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-tsveoIuX.css">
</head>
<body>

View File

@ -15,7 +15,8 @@
"tailwind-scrollbar": "^3.0.5",
"tailwindcss": "^3.4.0",
"vue": "^3.3.11",
"vue-router": "^4.2.5"
"vue-router": "^4.2.5",
"vuex": "^4.1.0"
},
"devDependencies": {
"@vitejs/plugin-vue": "^4.5.2",
@ -2288,6 +2289,17 @@
"vue": "^3.2.0"
}
},
"node_modules/vuex": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/vuex/-/vuex-4.1.0.tgz",
"integrity": "sha512-hmV6UerDrPcgbSy9ORAtNXDr9M4wlNP4pEFKye4ujJF8oqgFFuxDCdOLS3eNoRTtq5O3hoBDh9Doj1bQMYHRbQ==",
"dependencies": {
"@vue/devtools-api": "^6.0.0-beta.11"
},
"peerDependencies": {
"vue": "^3.2.0"
}
},
"node_modules/which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",

View File

@ -16,7 +16,8 @@
"tailwind-scrollbar": "^3.0.5",
"tailwindcss": "^3.4.0",
"vue": "^3.3.11",
"vue-router": "^4.2.5"
"vue-router": "^4.2.5",
"vuex": "^4.1.0"
},
"devDependencies": {
"@vitejs/plugin-vue": "^4.5.2",

View File

@ -25,9 +25,15 @@ import socketio
root_path = Path(__file__).parent.parent.parent.parent
global_path = root_path/"global_paths_cfg.yaml"
ASCIIColors.yellow(f"global_path: {global_path}")
lollms_paths = LollmsPaths(global_path)
config = LOLLMSConfig(lollms_paths.personal_configuration_path/"local_config.yaml")
if global_path.exists():
ASCIIColors.yellow(f"global_path: {global_path}")
lollms_paths = LollmsPaths(global_path)
config = LOLLMSConfig.autoload(lollms_paths,lollms_paths.personal_configuration_path/"local_config.yaml")
else:
ASCIIColors.yellow(f"global_path: {global_path}")
lollms_paths = LollmsPaths(global_path)
config = LOLLMSConfig.autoload(lollms_paths,lollms_paths.personal_configuration_path/"local_config.yaml")
shared_folder = lollms_paths.personal_path/"shared"
sd_folder = shared_folder / "auto_sd"
output_dir = lollms_paths.personal_path / "outputs/sd"
@ -48,7 +54,15 @@ sio = socketio.AsyncServer(async_mode='asgi')
app = FastAPI(debug=True)
app.mount("/socket.io", socketio.ASGIApp(sio))
lollms_app = LollmsApplication("lollms_installer",config=config,lollms_paths=lollms_paths, load_binding=False, load_model=False, socketio=sio)
lollms_app = LollmsApplication(
"lollms_installer",
config=config,
lollms_paths=lollms_paths,
load_binding=False,
load_model=False,
load_voice_service=False,
load
socketio=sio)
# Serve the index.html file for all routes
@app.get("/{full_path:path}")

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
View File

@ -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-9c145613.js"></script>
<link rel="stylesheet" href="/assets/index-7721818b.css">
<script type="module" crossorigin src="/assets/index-503d2057.js"></script>
<link rel="stylesheet" href="/assets/index-63438daa.css">
</head>
<body>
<div id="app"></div>

View File

@ -710,7 +710,110 @@
</tr>
</table>
</Card>
<Card title="Boost" :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="positive_boost" class="text-sm font-bold" style="margin-right: 1rem;">Positive Boost:</label>
</td>
<td>
<div class="flex flex-row">
<input
type="text"
id="positive_boost"
required
v-model="configFile.positive_boost"
@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="negative_boost" class="text-sm font-bold" style="margin-right: 1rem;">Negative Boost:</label>
</td>
<td>
<div class="flex flex-row">
<input
type="text"
id="negative_boost"
required
v-model="configFile.negative_boost"
@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="force_output_language_to_be" class="text-sm font-bold" style="margin-right: 1rem;">Force AI to answer in this language:</label>
</td>
<td>
<div class="flex flex-row">
<input
type="text"
id="force_output_language_to_be"
required
v-model="configFile.force_output_language_to_be"
@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="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">
<tr>
<td style="min-width: 200px;">
<label for="enable_sd_service" class="text-sm font-bold" style="margin-right: 1rem;">Enable sd service:</label>
</td>
<td>
<div class="flex flex-row">
<input
type="checkbox"
id="enable_sd_service"
required
v-model="configFile.enable_sd_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="install_sd_service" class="text-sm font-bold" style="margin-right: 1rem;">Reinstall SD service:</label>
</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>
</div>
</td>
</tr>
<tr>
<td style="min-width: 200px;">
<label for="sd_base_url" class="text-sm font-bold" style="margin-right: 1rem;">sd base url:</label>
</td>
<td>
<div class="flex flex-row">
<input
type="text"
id="sd_base_url"
required
v-model="configFile.sd_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>
@ -2031,6 +2134,16 @@ export default {
//refreshHardwareUsage()
},
methods: {
reinstallSDService(){
axios.get('install_sd')
.then(response => {
})
.catch(error => {
console.error(error);
});
},
reinstallAudioService(){
axios.get('install_xtts')
.then(response => {

@ -1 +1 @@
Subproject commit 388b01a281d09be801fad61c660537fef52cf018
Subproject commit 1194248d00606c69f9edb5d2b5fcf12c5fe23ee9