mirror of
https://github.com/ParisNeo/lollms-webui.git
synced 2025-01-19 03:06:23 +00:00
commit
3f70c8a909
@ -575,7 +575,8 @@ class LoLLMsAPPI():
|
||||
|
||||
message = data["prompt"]
|
||||
message_id = self.current_discussion.add_message(
|
||||
"user", message, parent=self.message_id
|
||||
"user", message, parent=self.message_id,model = self.config["model_name"],
|
||||
personality=self.config["personalities"][self.config["active_personality_id"]]
|
||||
)
|
||||
|
||||
self.current_user_message_id = message_id
|
||||
@ -675,7 +676,8 @@ class LoLLMsAPPI():
|
||||
self.personality.name, self.personality.welcome_message,
|
||||
DiscussionsDB.MSG_TYPE_NORMAL,
|
||||
0,
|
||||
-1
|
||||
-1,model = self.config["model_name"],
|
||||
personality=self.config["personalities"][self.config["active_personality_id"]]
|
||||
)
|
||||
|
||||
self.current_ai_message_id = message_id
|
||||
|
34
api/db.py
34
api/db.py
@ -20,7 +20,7 @@ class DiscussionsDB:
|
||||
"""
|
||||
create database schema
|
||||
"""
|
||||
db_version = 3
|
||||
db_version = 4
|
||||
# Verify encoding and change it if it is not complient
|
||||
with sqlite3.connect(self.db_path) as conn:
|
||||
# Execute a PRAGMA statement to get the current encoding of the database
|
||||
@ -65,6 +65,8 @@ class DiscussionsDB:
|
||||
cursor.execute("""
|
||||
CREATE TABLE message (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
model TEXT,
|
||||
personality TEXT,
|
||||
sender TEXT NOT NULL,
|
||||
content TEXT NOT NULL,
|
||||
type INT NOT NULL,
|
||||
@ -101,6 +103,9 @@ class DiscussionsDB:
|
||||
cursor.execute("ALTER TABLE message ADD COLUMN created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP") # Added in V3
|
||||
cursor.execute("ALTER TABLE discussion ADD COLUMN created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP") # Added in V3
|
||||
|
||||
cursor.execute("ALTER TABLE message ADD COLUMN model TEXT DEFAULT ''") # Added in V4
|
||||
cursor.execute("ALTER TABLE message ADD COLUMN personality INT DEFAULT ''") # Added in V4
|
||||
|
||||
# Upgrade the schema to version 1
|
||||
elif version < 2:
|
||||
print(f"Upgrading schema to version {db_version}...")
|
||||
@ -110,6 +115,9 @@ class DiscussionsDB:
|
||||
cursor.execute("ALTER TABLE message ADD COLUMN parent INT DEFAULT 0") # Added in V2
|
||||
cursor.execute("ALTER TABLE message ADD COLUMN created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP") # Added in V3
|
||||
cursor.execute("ALTER TABLE discussion ADD COLUMN created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP") # Added in V3
|
||||
|
||||
cursor.execute("ALTER TABLE message ADD COLUMN model TEXT DEFAULT ''") # Added in V4
|
||||
cursor.execute("ALTER TABLE message ADD COLUMN personality INT DEFAULT ''") # Added in V4
|
||||
except :
|
||||
pass
|
||||
# Upgrade the schema to version 1
|
||||
@ -120,6 +128,20 @@ class DiscussionsDB:
|
||||
try:
|
||||
cursor.execute("ALTER TABLE message ADD COLUMN created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP") # Added in V3
|
||||
cursor.execute("ALTER TABLE discussion ADD COLUMN created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP") # Added in V3
|
||||
cursor.execute("ALTER TABLE message ADD COLUMN model TEXT DEFAULT ''") # Added in V4
|
||||
cursor.execute("ALTER TABLE message ADD COLUMN personality INT DEFAULT ''") # Added in V4
|
||||
|
||||
except :
|
||||
pass
|
||||
# Upgrade the schema to version 1
|
||||
elif version < 4:
|
||||
print(f"Upgrading schema to version {db_version}...")
|
||||
# Add the 'created_at' column to the 'message' table
|
||||
if message_table_exist:
|
||||
try:
|
||||
cursor.execute("ALTER TABLE message ADD COLUMN model TEXT DEFAULT ''") # Added in V4
|
||||
cursor.execute("ALTER TABLE message ADD COLUMN personality INT DEFAULT ''") # Added in V4
|
||||
|
||||
except :
|
||||
pass
|
||||
# Update the schema version
|
||||
@ -311,7 +333,7 @@ class Discussion:
|
||||
self.discussion_id = discussion_id
|
||||
self.discussions_db = discussions_db
|
||||
|
||||
def add_message(self, sender, content, message_type=0, rank=0, parent=0):
|
||||
def add_message(self, sender, content, message_type=0, rank=0, parent=0, model ="", personality=""):
|
||||
"""Adds a new message to the discussion
|
||||
|
||||
Args:
|
||||
@ -322,8 +344,8 @@ class Discussion:
|
||||
int: The added message id
|
||||
"""
|
||||
message_id = self.discussions_db.insert(
|
||||
"INSERT INTO message (sender, content, type, rank, parent, discussion_id) VALUES (?, ?, ?, ?, ?, ?)",
|
||||
(sender, content, message_type, rank, parent, self.discussion_id)
|
||||
"INSERT INTO message (sender, content, type, rank, parent, model, personality, discussion_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
(sender, content, message_type, rank, parent, model, personality, self.discussion_id)
|
||||
)
|
||||
return message_id
|
||||
|
||||
@ -354,10 +376,10 @@ class Discussion:
|
||||
list: List of entries in the format {"id":message id, "sender":sender name, "content":message content, "type":message type, "rank": message rank}
|
||||
"""
|
||||
rows = self.discussions_db.select(
|
||||
"SELECT * FROM message WHERE discussion_id=?", (self.discussion_id,)
|
||||
"SELECT id, sender, content, type, rank, parent, model, personality FROM message WHERE discussion_id=?", (self.discussion_id,)
|
||||
)
|
||||
|
||||
return [{"id": row[0], "sender": row[1], "content": row[2], "type": row[3], "rank": row[4], "parent": row[5]} for row in rows]
|
||||
return [{"id": row[0], "sender": row[1], "content": row[2], "type": row[3], "rank": row[4], "parent": row[5], "model": row[6], "personality": row[7]} for row in rows]
|
||||
|
||||
def update_message(self, message_id, new_content):
|
||||
"""Updates the content of a message
|
||||
|
11
app.py
11
app.py
@ -777,11 +777,12 @@ class LoLLMsWebUI(LoLLMsAPPI):
|
||||
if self.config["active_personality_id"]>=index:
|
||||
self.config["active_personality_id"]=0
|
||||
if len(self.config["personalities"])>0:
|
||||
self.personalities = self.process.rebuild_personalities()
|
||||
self.mounted_personalities = self.process.rebuild_personalities()
|
||||
self.personality = self.mounted_personalities[self.config["active_personality_id"]]
|
||||
else:
|
||||
self.personalities = []
|
||||
self.personality = None
|
||||
self.personalities = ["english/generic/lollms"]
|
||||
self.mounted_personalities = self.process.rebuild_personalities()
|
||||
self.personality = self.mounted_personalities[self.config["active_personality_id"]]
|
||||
self.apply_settings()
|
||||
ASCIIColors.success("ok")
|
||||
return jsonify({
|
||||
@ -790,14 +791,14 @@ class LoLLMsWebUI(LoLLMsAPPI):
|
||||
"active_personality_id":self.config["active_personality_id"]
|
||||
})
|
||||
except:
|
||||
ASCIIColors.error(f"nok : Personality not found @ {pth}")
|
||||
ASCIIColors.error(f"nok : Personality not found @ {language}/{category}/{name}")
|
||||
return jsonify({"status": False, "error":"Couldn't unmount personality"})
|
||||
|
||||
def select_personality(self):
|
||||
print("- Selecting active personality ...",end="")
|
||||
|
||||
data = request.get_json()
|
||||
id = data['id']
|
||||
print(f"- Selecting active personality {id} ...",end="")
|
||||
if id<len(self.config["personalities"]):
|
||||
self.config["active_personality_id"]=id
|
||||
self.personality = self.mounted_personalities[self.config["active_personality_id"]]
|
||||
|
@ -1,7 +1,7 @@
|
||||
# =================== Lord Of Large Language Models Configuration file ===========================
|
||||
version: 7
|
||||
binding_name: llama_cpp_official
|
||||
model_name: airoboros-13b-gpt4.ggmlv3.q4_0.bin
|
||||
binding_name: gpt4all
|
||||
model_name: ggml-gpt4all-j-v1.3-groovy.bin
|
||||
|
||||
# Host information
|
||||
host: localhost
|
||||
|
1
web/dist/assets/index-3a0806cb.css
vendored
1
web/dist/assets/index-3a0806cb.css
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
web/dist/assets/index-d5a22ec2.css
vendored
Normal file
1
web/dist/assets/index-d5a22ec2.css
vendored
Normal file
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>GPT4All - WEBUI</title>
|
||||
<script type="module" crossorigin src="/assets/index-5f487c0a.js"></script>
|
||||
<link rel="stylesheet" href="/assets/index-3a0806cb.css">
|
||||
<script type="module" crossorigin src="/assets/index-5903b487.js"></script>
|
||||
<link rel="stylesheet" href="/assets/index-d5a22ec2.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
@ -13,7 +13,10 @@
|
||||
<!-- SENDER NAME -->
|
||||
<div class="flex ">
|
||||
<p class="drop-shadow-sm text-lg text-opacity-95 font-bold grow ">{{ message.sender }}</p>
|
||||
|
||||
<button @click="toggleModel" class="expand-button">{{ expanded ? ' - ' : ' + ' }}</button>
|
||||
<p v-if="expanded" class="drop-shadow-sm text-lg text-opacity-95 font-bold grow">
|
||||
{{ message.model }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex-grow ">
|
||||
|
||||
@ -100,7 +103,17 @@
|
||||
|
||||
</div>
|
||||
</template>
|
||||
<style>
|
||||
|
||||
.expand-button {
|
||||
margin-left: 10px; /* Add space between sender and expand button */
|
||||
margin-right: 10px; /* Add space between sender and expand button */
|
||||
background: none;
|
||||
border: none;
|
||||
padding: 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
import botImgPlaceholder from "../assets/logo.svg"
|
||||
import userImgPlaceholder from "../assets/default_user.svg"
|
||||
@ -121,7 +134,7 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
||||
expanded: false,
|
||||
|
||||
new_message_content: '',
|
||||
showConfirmation: false,
|
||||
@ -142,6 +155,9 @@ export default {
|
||||
})
|
||||
|
||||
}, methods: {
|
||||
toggleModel() {
|
||||
this.expanded = !this.expanded;
|
||||
},
|
||||
copyContentToClipboard() {
|
||||
this.$emit('copy', this.message.content)
|
||||
|
||||
|
@ -1432,7 +1432,8 @@ export default {
|
||||
const lastPers = this.mountedPersArr[this.mountedPersArr.length - 1]
|
||||
|
||||
console.log(lastPers, this.mountedPersArr.length)
|
||||
const res2 = await this.select_personality(lastPers.personality)
|
||||
// const res2 = await this.select_personality(lastPers.personality)
|
||||
const res2 = await this.select_personality(pers.personality)
|
||||
if (res2.status) {
|
||||
this.$refs.toast.showToast("Selected personality:\n" + lastPers.name, 4, true)
|
||||
|
||||
@ -1448,23 +1449,21 @@ export default {
|
||||
getMountedPersonalities() {
|
||||
|
||||
let mountedPersArr = []
|
||||
if (this.configFile.personalities.length > 0) {
|
||||
|
||||
console.log(this.configFile.personalities.length)
|
||||
// console.log('perrs listo',this.personalities)
|
||||
for (let i = 0; i < this.configFile.personalities.length; i++) {
|
||||
const full_path_item = this.configFile.personalities[i]
|
||||
//console.log('perrs listo',this.personalities)
|
||||
const index = this.personalities.findIndex(item => item.full_path == full_path_item)
|
||||
if (index) {
|
||||
|
||||
console.log('index',index)
|
||||
console.log("i:",i)
|
||||
const pers = this.personalities[index]
|
||||
if (pers) {
|
||||
mountedPersArr.push(pers)
|
||||
|
||||
}
|
||||
else{
|
||||
mountedPersArr.push(this.personalities[this.personalities.findIndex(item => item.full_path == "english/generic/lollms")])
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
this.mountedPersArr = []
|
||||
this.mountedPersArr = mountedPersArr
|
||||
//this.mountedPersArr = mountedPersArr
|
||||
|
Loading…
Reference in New Issue
Block a user