mirror of
https://github.com/ParisNeo/lollms-webui.git
synced 2025-02-21 01:31:20 +00:00
Merge branch 'main' into dev
This commit is contained in:
commit
962e7bd4e5
@ -396,7 +396,8 @@ class LoLLMsAPPI():
|
||||
message = data["prompt"]
|
||||
message_id = self.current_discussion.add_message(
|
||||
"user",
|
||||
message,
|
||||
message,
|
||||
message_type=DiscussionsDB.MSG_TYPE_NORMAL_USER,
|
||||
parent=self.message_id
|
||||
)
|
||||
|
||||
@ -631,8 +632,8 @@ class LoLLMsAPPI():
|
||||
|
||||
if self.personality.welcome_message!="":
|
||||
message_id = self.current_discussion.add_message(
|
||||
self.personality.name, self.personality.welcome_message,
|
||||
DiscussionsDB.MSG_TYPE_NORMAL,
|
||||
self.personality.name, self.personality.welcome_message,
|
||||
DiscussionsDB.MSG_TYPE_NORMAL_AI if self.personality.include_welcome_message_in_disucssion else DiscussionsDB.MSG_TYPE_USER_ONLY,
|
||||
0,
|
||||
-1,
|
||||
binding= self.config["binding_name"],
|
||||
@ -664,7 +665,7 @@ class LoLLMsAPPI():
|
||||
self.full_message_list = []
|
||||
for message in messages:
|
||||
if message["id"]< message_id or message_id==-1:
|
||||
if message["type"]==self.db.MSG_TYPE_NORMAL:
|
||||
if message["type"]==self.db.MSG_TYPE_NORMAL_USER or message["type"]==self.db.MSG_TYPE_NORMAL_AI:
|
||||
if message["sender"]==self.personality.name:
|
||||
self.full_message_list.append(self.personality.ai_message_prefix+message["content"])
|
||||
else:
|
||||
@ -879,10 +880,11 @@ class LoLLMsAPPI():
|
||||
self.current_ai_message_id = self.current_discussion.add_message(
|
||||
self.personality.name,
|
||||
"",
|
||||
parent = self.current_user_message_id,
|
||||
binding = self.config["binding_name"],
|
||||
model = self.config["model_name"],
|
||||
personality = self.config["personalities"][self.config["active_personality_id"]]
|
||||
message_type = DiscussionsDB.MSG_TYPE_NORMAL_AI,
|
||||
parent = self.current_user_message_id,
|
||||
binding = self.config["binding_name"],
|
||||
model = self.config["model_name"],
|
||||
personality = self.config["personalities"][self.config["active_personality_id"]]
|
||||
) # first the content is empty, but we'll fill it at the end
|
||||
self.socketio.emit('infos',
|
||||
{
|
||||
|
16
api/db.py
16
api/db.py
@ -12,8 +12,12 @@ __license__ = "Apache 2.0"
|
||||
|
||||
# =================================== Database ==================================================================
|
||||
class DiscussionsDB:
|
||||
MSG_TYPE_NORMAL = 0
|
||||
MSG_TYPE_CONDITIONNING = 1
|
||||
MSG_TYPE_NORMAL_USER = 0 # A normal message from user
|
||||
MSG_TYPE_NORMAL_AI = 1 # A normal message from ai
|
||||
|
||||
MSG_TYPE_CONDITIONNING = 2 # This is the AI conditionning (to be protected from window sliding)
|
||||
MSG_TYPE_HIDDEN = 3 # Don't show this to user
|
||||
MSG_TYPE_USER_ONLY = 4 # Don't give this to the AI
|
||||
|
||||
def __init__(self, db_path="database.db"):
|
||||
self.db_path = Path(db_path)
|
||||
@ -21,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()
|
||||
|
||||
@ -54,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)
|
||||
)
|
||||
@ -90,6 +95,7 @@ class DiscussionsDB:
|
||||
'rank',
|
||||
'parent',
|
||||
'created_at',
|
||||
'metadata',
|
||||
'finished_generating_at',
|
||||
'discussion_id'
|
||||
]
|
||||
@ -105,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
37
app.py
@ -982,15 +982,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")
|
||||
@ -1003,6 +994,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)
|
||||
@ -1046,24 +1047,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({})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -83,8 +83,15 @@ 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.
|
||||
|
||||
As you can see, generative AI has a huge potential to help us enhance our productivity. This tool is a little glimpse of what AI models especially generative models are capable of. AI is a tool, it can be used for good, as for bad. I hope you use this tool wizely and bare in mind that the future of humanity may depend on how we use these technologies. It is now impossible to stop AI development but we should tame it and make sure that its goals are aligned with ours. It can lead us to a bright future where we fix urgent problems like climate change and resource depletion, where we aceive great science discoveries, like building a better physics theory that can fuse quantum physics and general relativity. Or it can lead us to a dark world where AI empowers a handful of ritch people and enslaves the rest. I personally think that open source is the way to ensure fair access to every one to those tools.
|
||||
|
||||
I hope that you have liked this video. If you did, please consider leaving a thumb up, a sub to the channel and a comment. Thank you for watching. C ya
|
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-d867bca8.js"></script>
|
||||
<link rel="stylesheet" href="/assets/index-dda20b95.css">
|
||||
<script type="module" crossorigin src="/assets/index-3ae5f636.js"></script>
|
||||
<link rel="stylesheet" href="/assets/index-54172bba.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
75
web/package-lock.json
generated
75
web/package-lock.json
generated
@ -14,8 +14,11 @@
|
||||
"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",
|
||||
"markdown-it-multimd-table": "^4.2.2",
|
||||
"papaparse": "^5.4.1",
|
||||
"prismjs": "^1.29.0",
|
||||
"socket.io-client": "^4.6.1",
|
||||
@ -37,6 +40,15 @@
|
||||
"vite": "^4.1.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@aashutoshrathi/word-wrap": {
|
||||
"version": "1.2.6",
|
||||
"resolved": "https://registry.npmjs.org/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz",
|
||||
"integrity": "sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/parser": {
|
||||
"version": "7.21.4",
|
||||
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.21.4.tgz",
|
||||
@ -602,6 +614,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 +2178,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 +2203,19 @@
|
||||
"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/markdown-it-multimd-table": {
|
||||
"version": "4.2.2",
|
||||
"resolved": "https://registry.npmjs.org/markdown-it-multimd-table/-/markdown-it-multimd-table-4.2.2.tgz",
|
||||
"integrity": "sha512-aIrxGBS/klf2Q10ua/YUhxEouyvS9+NZbME2b3q4YHOFUpHLdTrBqHKssDnX+KVmctcsdR0yQxhkJf8K7UGQ5g=="
|
||||
},
|
||||
"node_modules/mdurl": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz",
|
||||
@ -2321,17 +2377,17 @@
|
||||
}
|
||||
},
|
||||
"node_modules/optionator": {
|
||||
"version": "0.9.1",
|
||||
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz",
|
||||
"integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==",
|
||||
"version": "0.9.3",
|
||||
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.3.tgz",
|
||||
"integrity": "sha512-JjCoypp+jKn1ttEFExxhetCKeJt9zhAgAve5FXHixTvFDW/5aEktX9bufBKLRRMdU7bNtpLfcGu94B3cdEJgjg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@aashutoshrathi/word-wrap": "^1.2.3",
|
||||
"deep-is": "^0.1.3",
|
||||
"fast-levenshtein": "^2.0.6",
|
||||
"levn": "^0.4.1",
|
||||
"prelude-ls": "^1.2.1",
|
||||
"type-check": "^0.4.0",
|
||||
"word-wrap": "^1.2.3"
|
||||
"type-check": "^0.4.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8.0"
|
||||
@ -3235,15 +3291,6 @@
|
||||
"node": ">= 8"
|
||||
}
|
||||
},
|
||||
"node_modules/word-wrap": {
|
||||
"version": "1.2.3",
|
||||
"resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz",
|
||||
"integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/wrappy": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||
|
@ -16,8 +16,11 @@
|
||||
"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",
|
||||
"markdown-it-multimd-table": "^4.2.2",
|
||||
"papaparse": "^5.4.1",
|
||||
"prismjs": "^1.29.0",
|
||||
"socket.io-client": "^4.6.1",
|
||||
|
@ -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(attrs).use(anchor).use(implicitFigures).use(emoji); // Add attrs plugin for adding attributes to elements
|
||||
|
||||
|
||||
// ... register other languages
|
||||
|
@ -234,6 +234,14 @@ export default {
|
||||
|
||||
data() {
|
||||
return {
|
||||
// To be synced with the backend database types
|
||||
msgTypes: {
|
||||
MSG_TYPE_NORMAL_USER: 0,
|
||||
MSG_TYPE_NORMAL_AI: 1,
|
||||
MSG_TYPE_CONDITIONNING: 2,
|
||||
MSG_TYPE_HIDDEN: 3,
|
||||
MSG_TYPE_USER_ONLY: 4
|
||||
},
|
||||
list: [], // Discussion list
|
||||
tempList: [], // Copy of Discussion list (used for keeping the original list during filtering discussions/searching action)
|
||||
currentDiscussion: {}, // Current/selected discussion id
|
||||
@ -300,8 +308,13 @@ export default {
|
||||
this.setDiscussionLoading(id, this.loading)
|
||||
if (res) {
|
||||
// Filter out the user and bot entries
|
||||
this.discussionArr = res.data.filter((item) => item.type == 0)
|
||||
|
||||
this.discussionArr = res.data.filter((item) =>
|
||||
item.type == this.msgTypes.MSG_TYPE_NORMAL_AI ||
|
||||
item.type == this.msgTypes.MSG_TYPE_NORMAL_USER ||
|
||||
item.type == this.msgTypes.MSG_TYPE_USER_ONLY
|
||||
)
|
||||
console.log("this.discussionArr")
|
||||
console.log(this.discussionArr)
|
||||
}
|
||||
|
||||
}
|
||||
@ -598,12 +611,11 @@ export default {
|
||||
binding: msgObj.binding,
|
||||
content: msgObj.message,
|
||||
created_at: msgObj.created_at,
|
||||
type: msgObj.type,
|
||||
finished_generating_at: msgObj.finished_generating_at,
|
||||
id: msgObj.user_message_id,
|
||||
model: msgObj.model,
|
||||
|
||||
personality: msgObj.personality,
|
||||
|
||||
sender: msgObj.user,
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user