upgraded modules

This commit is contained in:
Saifeddine ALOUI 2023-04-14 00:47:20 +02:00
parent a6c19e8e79
commit 67eb707d54
7 changed files with 54 additions and 2 deletions

9
app.py
View File

@ -57,6 +57,10 @@ class Gpt4AllWebUI:
self.add_endpoint(
"/list_models", "list_models", self.list_models, methods=["GET"]
)
self.add_endpoint(
"/list_personalities", "list_personalities", self.list_personalities, methods=["GET"]
)
self.add_endpoint(
"/list_discussions", "list_discussions", self.list_discussions, methods=["GET"]
)
@ -128,6 +132,11 @@ class Gpt4AllWebUI:
models_dir = Path('./models') # replace with the actual path to the models folder
models = [f.name for f in models_dir.glob('*.bin')]
return jsonify(models)
def list_personalities(self):
personalities_dir = Path('./personalities') # replace with the actual path to the models folder
personalities = [f.name for f in personalities_dir.glob('*.yaml')]
return jsonify(personalities)
def list_discussions(self):
discussions = self.db.get_discussions()

BIN
static/images/reset_db.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -200,7 +200,10 @@ const actionBtns = document.querySelector('#action-buttons');
actionBtns.appendChild(exportDiscussionButton);
const newDiscussionBtn = document.querySelector('#new-discussion-btn');
const resetDBButton = document.querySelector('#reset-discussions-btn');
resetDBButton.addEventListener('click', () => {
});
newDiscussionBtn.addEventListener('click', () => {
const chatWindow = document.getElementById('chat-window');

View File

@ -144,6 +144,30 @@ function populate_models(){
}
});
// Fetch the list of .yaml files from the models subfolder
fetch('/list_personalities')
.then(response => response.json())
.then(data => {
if (Array.isArray(data)) {
// data is an array
const selectElement = document.getElementById('personalities');
data.forEach(filename => {
const optionElement = document.createElement('option');
optionElement.value = filename;
optionElement.textContent = filename;
selectElement.appendChild(optionElement);
});
// fetch('/get_args')
// .then(response=> response.json())
// .then(data=>{
// })
} else {
console.error('Expected an array, but received:', data);
}
});
}
populate_models()

View File

@ -1 +1,8 @@
This section is under development. Stay tuned.
This section is under development. Stay tuned.<br>
To have a glimpse of what extensions and options will be added, please look at my chatgpt-personality-selector google chrome extension:<br>
<br>
* <a href="https://chrome.google.com/webstore/detail/chatgpt-personality-selec/jdmpccdlifdkhniemenfmieffkdblahk?hl=en">https://chrome.google.com/webstore/detail/chatgpt-personality-selec/jdmpccdlifdkhniemenfmieffkdblahk?hl=en</a>
<br>
<br>
After installing the extension, go to <a href="chat.openai.com/chat"/> and the extension popup will apear.<br>
All personalities will be implemented to gpt4All and can be used with any llamacpp model.

View File

@ -4,6 +4,9 @@
<button id="new-discussion-btn" class="px-4 py-4 rounded hover:bg-gray-600">
<img src="/static/images/new_message.png" class="w-10 h-10">
</button>
<button id="reset-discussions-btn" class="px-4 py-4 rounded hover:bg-gray-600">
<img src="/static/images/reset_db.png" class="w-10 h-10">
</button>
<button value="Export" id="export-button" class="px-4 py-4 rounded hover:bg-gray-600">
<img src="/static/images/export_database.png" class="w-10 h-10">
</button>

View File

@ -5,6 +5,12 @@
<select class="bg-gray-700 shadow appearance-none border rounded w-full py-2 px-3 leading-tight focus:outline-none focus:shadow-outline" id="model" name="model" value="gpt4all-lora-quantized.bin">
</select>
</div>
<div class="mb-4">
<label class="block font-bold mb-2" for="model">Personalities</label>
<select class="bg-gray-700 shadow appearance-none border rounded w-full py-2 px-3 leading-tight focus:outline-none focus:shadow-outline" id="personalities" name="personalities" value="gpt4all_chatbot.yaml">
</select>
</div>
<div class="mb-4">
<label class="block font-bold mb-2" for="seed">Seed</label>
<input class="bg-gray-700 shadow appearance-none border rounded w-full py-2 px-3 leading-tight focus:outline-none focus:shadow-outline" id="seed" type="text" name="seed" value="0">
@ -23,7 +29,7 @@
</div>
<div class="mb-4">
<label class="block font-bold mb-2" for="top-p" id="top-p-value">Top P</label>
<input class="w-full slider-value" id="top-p" type="range" min="0" max="100" step="1" value="40" name="top-p">
<input class="w-full slider-value" id="top-p" type="range" min="0" max="1" step="0.1" value="0.95" name="top-p">
</div>
<div class="mb-4">
<label class="block font-bold mb-2" for="repeat-penalty" id="repeat-penalty-value">Repeat penalty</label>