mirror of
https://github.com/ParisNeo/lollms-webui.git
synced 2024-12-21 21:27:47 +00:00
Bugfix: empty database case
This commit is contained in:
parent
10dea92101
commit
85237770ad
10
db.py
10
db.py
@ -127,7 +127,7 @@ class DiscussionsDB:
|
|||||||
conn.commit()
|
conn.commit()
|
||||||
|
|
||||||
def load_last_discussion(self):
|
def load_last_discussion(self):
|
||||||
last_discussion_id = self.select("SELECT id FROM discussions 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)
|
||||||
if last_discussion_id is None:
|
if last_discussion_id is None:
|
||||||
last_discussion_id = self.create_discussion()
|
last_discussion_id = self.create_discussion()
|
||||||
else:
|
else:
|
||||||
@ -154,7 +154,11 @@ class DiscussionsDB:
|
|||||||
return [{"id": row[0], "title": row[1]} for row in rows]
|
return [{"id": row[0], "title": row[1]} for row in rows]
|
||||||
|
|
||||||
def does_last_discussion_have_messages(self):
|
def does_last_discussion_have_messages(self):
|
||||||
last_discussion_id = self.select("SELECT id FROM discussion ORDER BY id DESC LIMIT 1", fetch_all=False)[0]
|
last_discussion_id = self.select("SELECT id FROM discussion ORDER BY id DESC LIMIT 1", fetch_all=False)
|
||||||
|
if last_discussion_id is None:
|
||||||
|
last_discussion_id = self.create_discussion()
|
||||||
|
else:
|
||||||
|
last_discussion_id=last_discussion_id[0]
|
||||||
last_message = self.select("SELECT * FROM message WHERE discussion_id=?", (last_discussion_id,), fetch_all=False)
|
last_message = self.select("SELECT * FROM message WHERE discussion_id=?", (last_discussion_id,), fetch_all=False)
|
||||||
return last_message is not None
|
return last_message is not None
|
||||||
|
|
||||||
@ -169,7 +173,7 @@ class DiscussionsDB:
|
|||||||
for row in db_discussions:
|
for row in db_discussions:
|
||||||
discussion_id = row[0]
|
discussion_id = row[0]
|
||||||
discussion = {"id": discussion_id, "messages": []}
|
discussion = {"id": discussion_id, "messages": []}
|
||||||
rows = self.select(f"SELECT * FROM message WHERE discussion_id={discussion_id}")
|
rows = self.select(f"SELECT * FROM message WHERE discussion_id=?",(discussion_id))
|
||||||
for message_row in rows:
|
for message_row in rows:
|
||||||
discussion["messages"].append(
|
discussion["messages"].append(
|
||||||
{"sender": message_row[1], "content": message_row[2]}
|
{"sender": message_row[1], "content": message_row[2]}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/tailwindcss.css') }}">
|
<link rel="stylesheet" href="{{ url_for('static', filename='css/tailwindcss.css') }}">
|
||||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/chat.css') }}">
|
<link rel="stylesheet" href="{{ url_for('static', filename='css/chat.css') }}">
|
||||||
</head>
|
</head>
|
||||||
<body class="w-screen h-screen bg-primary text-gray-400 flex flex-col overflow-hidden">
|
<body class="w-screen h-full bg-primary text-gray-400 flex flex-col">
|
||||||
<div class="w-full h-20 border-b border-accent bg-tertiary text-2xl font-bold flex justify-between items-center px-6">
|
<div class="w-full h-20 border-b border-accent bg-tertiary text-2xl font-bold flex justify-between items-center px-6">
|
||||||
<div class="w-12 h-12"><img src="{{ url_for('static', filename='images/icon.png') }}"></div>
|
<div class="w-12 h-12"><img src="{{ url_for('static', filename='images/icon.png') }}"></div>
|
||||||
<h1>GPT4All - WEBUI</h1>
|
<h1>GPT4All - WEBUI</h1>
|
||||||
@ -22,7 +22,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div id="main" class="tab-pane flex flex-col">
|
<div id="main" class="tab-pane flex flex-col">
|
||||||
<div class="w-1/3 bg-gray-200 flex flex-row border-r border-gray-400 h-screen">
|
<div class="w-1/3 bg-gray-200 flex flex-row">
|
||||||
<section>
|
<section>
|
||||||
<section id="action-buttons" class="flex-none md:border-b border-accent flex flex-row md:flex-row">
|
<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">
|
<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">
|
||||||
@ -38,12 +38,12 @@
|
|||||||
<div>
|
<div>
|
||||||
<h1>Discussions</h1>
|
<h1>Discussions</h1>
|
||||||
</div>
|
</div>
|
||||||
<div id="discussions-list" class="overflow-y-auto h-full">
|
<div id="discussions-list" class="overflow-y-auto">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<div class="flex-coll w-full h-screen">
|
<section class="flex-coll w-full">
|
||||||
<div id="chat-window" class="w-2/3 overflow-y-auto flex flex-col flex-1">
|
<div id="chat-window" class="w-2/3 overflow-y-auto flex flex-col h-500">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<form id="chat-form" class="flex w-full mt-auto">
|
<form id="chat-form" class="flex w-full mt-auto">
|
||||||
@ -51,7 +51,7 @@
|
|||||||
<input type="submit" value="Send" id="submit-input" 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="submit" value="Send" id="submit-input" 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">
|
||||||
<div id="wait-animation" style="display: none;" class="lds-facebook bg-secondary my-1 mx-1 outline-none drop-shadow-sm w-full rounded-md p-2"><div></div><div></div><div></div></div>
|
<div id="wait-animation" style="display: none;" class="lds-facebook bg-secondary my-1 mx-1 outline-none drop-shadow-sm w-full rounded-md p-2"><div></div><div></div><div></div></div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="tab-pane" id="settings" style="display: non;">
|
<div class="tab-pane" id="settings" style="display: non;">
|
||||||
@ -68,28 +68,28 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="mb-4">
|
<div class="mb-4">
|
||||||
<label class="block text-gray-700 font-bold mb-2" for="temp">Temperature</label>
|
<label class="block text-gray-700 font-bold mb-2" for="temp">Temperature</label>
|
||||||
<input class="bg-gray-700 slider absolute top-0 w-full h-full opacity-0" id="temp" type="range" min="0" max="1" step="0.1" value="0.1" name="temp">
|
<input class="bg-gray-700 slider absolute top-0 w-full opacity-0" id="temp" type="range" min="0" max="1" step="0.1" value="0.1" name="temp">
|
||||||
<p id="slider-value">0.1</p>
|
<p id="slider-value">0.1</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-4">
|
<div class="mb-4">
|
||||||
<label class="block text-gray-700 font-bold mb-2" for="n-predict">N Predict</label>
|
<label class="block text-gray-700 font-bold mb-2" for="n-predict">N Predict</label>
|
||||||
<input class="bg-gray-700 slider absolute top-0 w-full h-full opacity-0" id="n-predict" type="range" min="0" max="2048" step="1" value="256" name="n-predict">
|
<input class="bg-gray-700 slider absolute top-0 w-full opacity-0" id="n-predict" type="range" min="0" max="2048" step="1" value="256" name="n-predict">
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-4">
|
<div class="mb-4">
|
||||||
<label class="block text-gray-700 font-bold mb-2" for="top-k">Top K</label>
|
<label class="block text-gray-700 font-bold mb-2" for="top-k">Top K</label>
|
||||||
<input class="bg-gray-700 slider absolute top-0 w-full h-full opacity-0" id="top-k" type="range" min="0" max="100" step="1" value="40" name="top-k">
|
<input class="bg-gray-700 slider absolute top-0 w-full opacity-0" id="top-k" type="range" min="0" max="100" step="1" value="40" name="top-k">
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-4">
|
<div class="mb-4">
|
||||||
<label class="block text-gray-700 font-bold mb-2" for="top-p">Top P</label>
|
<label class="block text-gray-700 font-bold mb-2" for="top-p">Top P</label>
|
||||||
<input class="bg-gray-700 slider absolute top-0 w-full h-full opacity-0" id="top-p" type="range" min="0" max="100" step="1" value="40" name="top-p">
|
<input class="bg-gray-700 slider absolute top-0 w-full opacity-0" id="top-p" type="range" min="0" max="100" step="1" value="40" name="top-p">
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-4">
|
<div class="mb-4">
|
||||||
<label class="block text-gray-700 font-bold mb-2" for="repeat-penalty">Repeat penalty</label>
|
<label class="block text-gray-700 font-bold mb-2" for="repeat-penalty">Repeat penalty</label>
|
||||||
<input class="bg-gray-700 slider absolute top-0 w-full h-full opacity-0" id="repeat-penalty" type="range" min="0" max="100" step="1" value="40" name="repeat-penalty">
|
<input class="bg-gray-700 slider absolute top-0 w-full opacity-0" id="repeat-penalty" type="range" min="0" max="100" step="1" value="40" name="repeat-penalty">
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-4">
|
<div class="mb-4">
|
||||||
<label class="block text-gray-700 font-bold mb-2" for="repeat-last-n">Repeat penalty</label>
|
<label class="block text-gray-700 font-bold mb-2" for="repeat-last-n">Repeat penalty</label>
|
||||||
<input class="bg-gray-700 slider absolute top-0 w-full h-full opacity-0" id="repeat-last-n" type="range" min="0" max="100" step="1" value="40" name="repeat-last-n">
|
<input class="bg-gray-700 slider absolute top-0 w-full opacity-0" id="repeat-last-n" type="range" min="0" max="100" step="1" value="40" name="repeat-last-n">
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-4">
|
<div class="mb-4">
|
||||||
<button type="submit" id="submit-model-params" 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">Update parameters</button>
|
<button type="submit" id="submit-model-params" 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">Update parameters</button>
|
||||||
|
Loading…
Reference in New Issue
Block a user