Enhanced message types

This commit is contained in:
Saifeddine ALOUI 2023-07-02 15:55:59 +02:00
parent 510aa8dba9
commit 9c16f8fae5
6 changed files with 37 additions and 19 deletions

View File

@ -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',
{

View File

@ -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)

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-d867bca8.js"></script>
<link rel="stylesheet" href="/assets/index-dda20b95.css">
<script type="module" crossorigin src="/assets/index-2eb5bb15.js"></script>
<link rel="stylesheet" href="/assets/index-54172bba.css">
</head>
<body>
<div id="app"></div>

View File

@ -232,6 +232,14 @@ export default {
setup() { },
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
@ -298,8 +306,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)
}
}
@ -596,12 +609,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,
}