This commit is contained in:
Saifeddine ALOUI 2023-07-03 00:17:01 +02:00
parent 9c16f8fae5
commit 4de4d112b2
8 changed files with 99 additions and 62 deletions

View File

@ -25,7 +25,7 @@ class DiscussionsDB:
def create_tables(self):
db_version = 6
db_version = 7
with sqlite3.connect(self.db_path) as conn:
cursor = conn.cursor()
@ -58,6 +58,7 @@ class DiscussionsDB:
created_at TIMESTAMP,
finished_generating_at TIMESTAMP,
discussion_id INTEGER NOT NULL,
metadata JSON,
FOREIGN KEY (discussion_id) REFERENCES discussion(id),
FOREIGN KEY (parent) REFERENCES message(id)
)
@ -94,6 +95,7 @@ class DiscussionsDB:
'rank',
'parent',
'created_at',
'metadata',
'finished_generating_at',
'discussion_id'
]
@ -109,9 +111,11 @@ class DiscussionsDB:
cursor.execute(f"ALTER TABLE {table} ADD COLUMN {column} INTEGER PRIMARY KEY AUTOINCREMENT")
elif column.endswith('_at'):
cursor.execute(f"ALTER TABLE {table} ADD COLUMN {column} TIMESTAMP")
elif column=='metadata':
cursor.execute(f"ALTER TABLE {table} ADD COLUMN {column} JSON")
else:
cursor.execute(f"ALTER TABLE {table} ADD COLUMN {column} TEXT")
ASCIIColors.yellow(f"Added column :{column}")
conn.commit()

37
app.py
View File

@ -980,15 +980,6 @@ class LoLLMsWebUI(LoLLMsAPPI):
else:
return jsonify({'status':False})
def get_active_binding_settings(self):
print("- Retreiving binding settings")
if self.binding is not None:
if hasattr(self.binding,"binding_config"):
return jsonify(self.binding.binding_config.config_template.template)
else:
return jsonify({})
else:
return jsonify({})
def set_active_binding_settings(self):
print("- Setting binding settings")
@ -1001,6 +992,16 @@ class LoLLMsWebUI(LoLLMsAPPI):
if self.binding is not None:
if hasattr(self.binding,"binding_config"):
for entry in data:
if entry["type"]=="list" and type(entry["value"])==str:
try:
v = json.loads(entry["value"])
except:
v= ""
if type(v)==list:
entry["value"] = v
else:
entry["value"] = [entry["value"]]
self.binding.binding_config.update_template(data)
self.binding.binding_config.config.save_config()
self.binding= BindingBuilder().build_binding(self.config, self.lollms_paths)
@ -1044,24 +1045,6 @@ class LoLLMsWebUI(LoLLMsAPPI):
def get_binding_settings(self):
print("- Retreiving personality settings")
try:
data = request.get_json()
# Further processing of the data
except Exception as e:
print(f"Error occurred while parsing JSON: {e}")
return
if personality.processor is not None:
if hasattr(personality.processor,"personality_config"):
return jsonify(personality.processor.personality_config.config_template.template)
else:
return jsonify({})
else:
return jsonify({})

View File

@ -83,8 +83,11 @@ pip install --upgrade lollms
This will install the library along with the server, a console generation tool and a settings tool.
Once the installation is done, just run lollms-server and follow the instruction. The first time you use it, it will ask for the path to your personal data folder. You can use the same folder as the webui if you want to mutualize your models and settings. The server bindings and model names are exclusive to each application. This is logical as if you want to use the lollms remote nodes for the client, you would use another binding for the server. In fact the server configuration file has a prefix lollms_server.
Now we need to come back to our web-ui and configure the servers we want to use. Here we used a local server, so we just use its name as http://localhost:9600 but you can run the server on a different PC. Just make sure you run the lollms-server with the option --host 0.0.0.0 which will expose the server on all ip adresses of your PC. You can also specify the IP address. You can run multiple servers on the same node by changing the port number using --port parameter of the lollms-server. You can also add multiple server paths in the configuration by separating them using a comma. Make sure this parameter is a list of strings put inside brackets just as in python.
Now we need to come back to our web-ui and configure the servers we want to use. Here we used a local server, so we just use its name as http://localhost:9601 but you can run the server on a different PC. Just make sure you run the lollms-server with the option --host 0.0.0.0 which will expose the server on all ip adresses of your PC. You can also specify the IP address. You can run multiple servers on the same node by changing the port number using --port parameter of the lollms-server. You can also add multiple server paths in the configuration by separating them using a comma. Make sure this parameter is a list of strings put inside brackets just as in python.
You can view in the console what servers are active at the moment. You can choose to completely remove the inactive servers from the list for the current session or to continue trying to connect to them whenever a new generation is attempted.
Now that our remote service is up, we can use it as we use any local binding.
Let's ask Carl sagan what is cosmos.
If we look at the Lollms console, we can see that it got the prompt and is generating the words.

File diff suppressed because one or more lines are too long

2
web/dist/index.html vendored
View File

@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>LoLLMS WebUI - Welcome</title>
<script type="module" crossorigin src="/assets/index-2eb5bb15.js"></script>
<script type="module" crossorigin src="/assets/index-0d62c0a3.js"></script>
<link rel="stylesheet" href="/assets/index-54172bba.css">
</head>
<body>

41
web/package-lock.json generated
View File

@ -14,8 +14,10 @@
"flowbite-vue": "^0.0.10",
"highlight.js": "^11.8.0",
"markdown-it": "^13.0.1",
"markdown-it-anchor": "^8.6.7",
"markdown-it-attrs": "^4.1.6",
"markdown-it-emoji": "^2.0.2",
"markdown-it-implicit-figures": "^0.11.0",
"papaparse": "^5.4.1",
"prismjs": "^1.29.0",
"socket.io-client": "^4.6.1",
@ -602,6 +604,28 @@
"resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.0.tgz",
"integrity": "sha512-+9jVqKhRSpsc591z5vX+X5Yyw+he/HCB4iQ/RYxw35CEPaY1gnsNE43nf9n9AaYjAQrTiI/mOwKUKdUs9vf7Xg=="
},
"node_modules/@types/linkify-it": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/@types/linkify-it/-/linkify-it-3.0.2.tgz",
"integrity": "sha512-HZQYqbiFVWufzCwexrvh694SOim8z2d+xJl5UNamcvQFejLY/2YUtzXHYi3cHdI7PMlS8ejH2slRAOJQ32aNbA==",
"peer": true
},
"node_modules/@types/markdown-it": {
"version": "12.2.3",
"resolved": "https://registry.npmjs.org/@types/markdown-it/-/markdown-it-12.2.3.tgz",
"integrity": "sha512-GKMHFfv3458yYy+v/N8gjufHO6MSZKCOXpZc5GXIWWy8uldwfmPn98vp81gZ5f9SVw8YYBctgfJ22a2d7AOMeQ==",
"peer": true,
"dependencies": {
"@types/linkify-it": "*",
"@types/mdurl": "*"
}
},
"node_modules/@types/mdurl": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@types/mdurl/-/mdurl-1.0.2.tgz",
"integrity": "sha512-eC4U9MlIcu2q0KQmXszyn5Akca/0jrQmwDRgpAMJai7qBWq4amIQhZyNau4VYGtCeALvW1/NtjzJJ567aZxfKA==",
"peer": true
},
"node_modules/@types/web-bluetooth": {
"version": "0.0.15",
"resolved": "https://registry.npmjs.org/@types/web-bluetooth/-/web-bluetooth-0.0.15.tgz",
@ -2144,6 +2168,15 @@
"markdown-it": "bin/markdown-it.js"
}
},
"node_modules/markdown-it-anchor": {
"version": "8.6.7",
"resolved": "https://registry.npmjs.org/markdown-it-anchor/-/markdown-it-anchor-8.6.7.tgz",
"integrity": "sha512-FlCHFwNnutLgVTflOYHPW2pPcl2AACqVzExlkGQNsi4CJgqOHN7YTgDd4LuhgN1BFO3TS0vLAruV1Td6dwWPJA==",
"peerDependencies": {
"@types/markdown-it": "*",
"markdown-it": "*"
}
},
"node_modules/markdown-it-attrs": {
"version": "4.1.6",
"resolved": "https://registry.npmjs.org/markdown-it-attrs/-/markdown-it-attrs-4.1.6.tgz",
@ -2160,6 +2193,14 @@
"resolved": "https://registry.npmjs.org/markdown-it-emoji/-/markdown-it-emoji-2.0.2.tgz",
"integrity": "sha512-zLftSaNrKuYl0kR5zm4gxXjHaOI3FAOEaloKmRA5hijmJZvSjmxcokOLlzycb/HXlUFWzXqpIEoyEMCE4i9MvQ=="
},
"node_modules/markdown-it-implicit-figures": {
"version": "0.11.0",
"resolved": "https://registry.npmjs.org/markdown-it-implicit-figures/-/markdown-it-implicit-figures-0.11.0.tgz",
"integrity": "sha512-ed32u3O8pTEM3TKgeBTMKw8ce86L8u5L41CuLvGee3yevYOq+1BoxjI84m/f7RcUaATcKgXTgZwieadvOH4afg==",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/mdurl": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz",

View File

@ -16,8 +16,10 @@
"flowbite-vue": "^0.0.10",
"highlight.js": "^11.8.0",
"markdown-it": "^13.0.1",
"markdown-it-anchor": "^8.6.7",
"markdown-it-attrs": "^4.1.6",
"markdown-it-emoji": "^2.0.2",
"markdown-it-implicit-figures": "^0.11.0",
"papaparse": "^5.4.1",
"prismjs": "^1.29.0",
"socket.io-client": "^4.6.1",

View File

@ -9,6 +9,8 @@ import { nextTick } from 'vue';
import feather from 'feather-icons';
import MarkdownIt from 'markdown-it';
import emoji from 'markdown-it-emoji';
import anchor from 'markdown-it-anchor';
import implicitFigures from 'markdown-it-implicit-figures';
//import hljs from 'highlight.js/lib/core';
import 'highlight.js/styles/tomorrow-night-blue.css';
import 'highlight.js/styles/tokyo-night-dark.css';
@ -26,7 +28,7 @@ function generateUniqueId() {
}
const markdownIt = new MarkdownIt('commonmark', {
html: false,
html: true,
xhtmlOut: true,
breaks: true,
linkify: true,
@ -90,7 +92,7 @@ const markdownIt = new MarkdownIt('commonmark', {
return codeString;
},
bulletListMarker: '•',
}).use(emoji).use(attrs); // Add attrs plugin for adding attributes to elements
}).use(emoji).use(attrs).use(anchor).use(implicitFigures); // Add attrs plugin for adding attributes to elements
// ... register other languages