mirror of
https://github.com/ParisNeo/lollms-webui.git
synced 2025-01-18 18:56:32 +00:00
enhanced UI
This commit is contained in:
parent
e8bbdaa6d1
commit
a431586f05
18
app.py
18
app.py
@ -113,13 +113,17 @@ class Gpt4AllWebUI:
|
||||
Instruction: Act as GPT4All. A kind and helpful AI bot built to help users solve problems.
|
||||
GPT4All:Welcome! I'm here to assist you with anything you need. What can I do for you today?"""
|
||||
):
|
||||
self.full_message += conditionning_message +"\n"
|
||||
if self.current_discussion is None or not self.db.does_last_discussion_have_messages():
|
||||
self.current_discussion = self.db.create_discussion()
|
||||
self.full_message += conditionning_message
|
||||
if self.current_discussion is None:
|
||||
if self.db.does_last_discussion_have_messages():
|
||||
self.current_discussion = self.db.create_discussion()
|
||||
else:
|
||||
self.current_discussion = self.db.load_last_discussion()
|
||||
|
||||
message_id = self.current_discussion.add_message(
|
||||
"conditionner", conditionning_message, DiscussionsDB.MSG_TYPE_CONDITIONNING,0
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
@ -256,8 +260,11 @@ GPT4All:Welcome! I'm here to assist you with anything you need. What can I do fo
|
||||
def bot(self):
|
||||
self.stop = True
|
||||
|
||||
if self.current_discussion is None or not self.db.does_last_discussion_have_messages():
|
||||
self.current_discussion = self.db.create_discussion()
|
||||
if self.current_discussion is None:
|
||||
if self.db.does_last_discussion_have_messages():
|
||||
self.current_discussion = self.db.create_discussion()
|
||||
else:
|
||||
self.current_discussion = self.db.load_last_discussion()
|
||||
|
||||
message_id = self.current_discussion.add_message(
|
||||
"user", request.json["message"]
|
||||
@ -274,7 +281,6 @@ GPT4All:Welcome! I'm here to assist you with anything you need. What can I do fo
|
||||
|
||||
def rename(self):
|
||||
data = request.get_json()
|
||||
discussion_id = data["id"]
|
||||
title = data["title"]
|
||||
self.current_discussion.rename(title)
|
||||
return "renamed successfully"
|
||||
|
9
db.py
9
db.py
@ -125,7 +125,11 @@ class DiscussionsDB:
|
||||
with sqlite3.connect(self.db_path) as conn:
|
||||
conn.execute(query, params)
|
||||
conn.commit()
|
||||
|
||||
|
||||
def load_last_discussion(self):
|
||||
last_discussion_id = self.select("SELECT id FROM discussions ORDER BY id DESC LIMIT 1", fetch_all=False)[0]
|
||||
return Discussion(last_discussion_id, self)
|
||||
|
||||
def create_discussion(self, title="untitled"):
|
||||
"""Creates a new discussion
|
||||
|
||||
@ -146,7 +150,8 @@ class DiscussionsDB:
|
||||
return [{"id": row[0], "title": row[1]} for row in rows]
|
||||
|
||||
def does_last_discussion_have_messages(self):
|
||||
last_message = self.select("SELECT * FROM message ORDER BY id DESC LIMIT 1", fetch_all=False)
|
||||
last_discussion_id = self.select("SELECT id FROM discussion ORDER BY id DESC LIMIT 1", fetch_all=False)[0]
|
||||
last_message = self.select("SELECT * FROM message WHERE discussion_id=?", (last_discussion_id,), fetch_all=False)
|
||||
return last_message is not None
|
||||
|
||||
def remove_discussions(self):
|
||||
|
BIN
static/images/export_database.png
Normal file
BIN
static/images/export_database.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.4 KiB |
BIN
static/images/export_discussion.png
Normal file
BIN
static/images/export_discussion.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
BIN
static/images/new_message.png
Normal file
BIN
static/images/new_message.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.5 KiB |
@ -165,23 +165,8 @@ function populate_discussions_list()
|
||||
populate_discussions_list()
|
||||
|
||||
// adding export discussion button
|
||||
const exportDiscussionButton = document.createElement('button');
|
||||
exportDiscussionButton.classList.add(
|
||||
'my-1',
|
||||
'mx-1',
|
||||
'outline-none',
|
||||
'px-4',
|
||||
'bg-accent',
|
||||
'text-black',
|
||||
'rounded-md',
|
||||
'hover:bg-[#7ba0ea]',
|
||||
'active:bg-[#3d73e1]',
|
||||
'transition-colors',
|
||||
'ease-in-out'
|
||||
);
|
||||
exportDiscussionButton.style.float = 'right'; // set the float property to right
|
||||
exportDiscussionButton.style.display='inline-block'
|
||||
exportDiscussionButton.innerHTML = 'Export discussion to text';
|
||||
const exportDiscussionButton = document.querySelector('#export-discussion-button');
|
||||
|
||||
exportDiscussionButton.addEventListener('click', () => {
|
||||
fetch(`/export_discussion`)
|
||||
.then(response => response.text())
|
||||
|
@ -21,10 +21,21 @@
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="main" class="tab-pane h-full flex flex-row md:flex-row overflow-hidden max-h-full">
|
||||
<div class="w-1/3 bg-gray-200 flex flex-row border-r border-gray-400 h-full">
|
||||
<div class="w-1/3 bg-gray-200 flex flex-col border-r border-gray-400 h-full">
|
||||
<section class="md:h-1/2 md:border-b border-accent flex flex md:flex-col h-full">
|
||||
<div id="main" class="tab-pane absolute inset-0 border-4 border-red-500 h-full">
|
||||
<div class="absolute inset-0 border-4 border-red-500 w-1/3 bg-gray-200 flex flex-row border-r border-gray-400 h-full">
|
||||
<div class="absolute inset-0 border-4 border-red-500">
|
||||
<section class="flex-1 absolute inset-0 border-4 border-red-500 overflow-y-auto h-full">
|
||||
<section id="action-buttons" class="flex-none md:border-b border-accent flex flex-row md:flex-row">
|
||||
<button id="new-discussion-btn" class="my-1 mx-1 outline-none px-4 bg-accent text-black rounded-md hover:bg-[#7ba0ea] active:bg-[#3d73e1] transition-colors ease-in-out">
|
||||
<img src="/static/images/new_message.png" style="width: 20px;height: 20px;">
|
||||
</button>
|
||||
<button value="Export" id="export-button" class="my-1 mx-1 outline-none px-4 bg-accent text-black rounded-md hover:bg-[#7ba0ea] active:bg-[#3d73e1] transition-colors ease-in-out">
|
||||
<img src="/static/images/export_database.png" style="width: 20px;height: 20px;">
|
||||
</button>
|
||||
<button value="Export" id="export-discussion-button" class="my-1 mx-1 outline-none px-4 bg-accent text-black rounded-md hover:bg-[#7ba0ea] active:bg-[#3d73e1] transition-colors ease-in-out">
|
||||
<img src="/static/images/export_discussion.png" style="width: 20px;height: 20px;">
|
||||
</button>
|
||||
</section>
|
||||
<div>
|
||||
<h1>Discussions</h1>
|
||||
</div>
|
||||
@ -32,10 +43,6 @@
|
||||
|
||||
</div>
|
||||
</section>
|
||||
<section id="action-buttons" class="md:border-b border-accent flex flex md:flex-col">
|
||||
<input type="button" value="New Discussion" id="new-discussion-btn" class="my-1 mx-1 outline-none px-4 bg-accent text-black rounded-md hover:bg-[#7ba0ea] active:bg-[#3d73e1] transition-colors ease-in-out">
|
||||
<input type="button" value="Export" id="export-button" class="my-1 mx-1 outline-none px-4 bg-accent text-black rounded-md hover:bg-[#7ba0ea] active:bg-[#3d73e1] transition-colors ease-in-out">
|
||||
</section>
|
||||
</div>
|
||||
<div id="chat-window" class="w-2/3 overflow-y-auto flex flex-col max-h-full">
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user