Upgraded ui

This commit is contained in:
saloui 2023-06-07 09:39:38 +02:00
parent 584a1f6f03
commit 864578cd48
13 changed files with 200 additions and 91 deletions

View File

@ -108,9 +108,9 @@ class ModelProcess:
def reset_config_result(self):
self._set_config_result = {
'status': 'succeeded',
'binding_status':'ok',
'model_status':'ok',
'personality_status':'ok',
'binding_status':True,
'model_status':True,
'personality_status':True,
'errors':[]
}

51
app.py
View File

@ -84,6 +84,8 @@ class LoLLMsWebUI(LoLLMsAPPI):
# =========================================================================================
# Endpoints
# =========================================================================================
self.add_endpoint("/add_reference_to_local_model", "add_reference_to_local_model", self.add_reference_to_local_model, methods=["POST"])
self.add_endpoint("/send_file", "send_file", self.send_file, methods=["POST"])
@ -131,6 +133,8 @@ class LoLLMsWebUI(LoLLMsAPPI):
self.add_endpoint("/bindings/<path:filename>", "serve_bindings", self.serve_bindings, methods=["GET"])
self.add_endpoint("/personalities/<path:filename>", "serve_personalities", self.serve_personalities, methods=["GET"])
self.add_endpoint("/outputs/<path:filename>", "serve_outputs", self.serve_outputs, methods=["GET"])
self.add_endpoint("/data/<path:filename>", "serve_data", self.serve_data, methods=["GET"])
self.add_endpoint("/uploads/<path:filename>", "serve_uploads", self.serve_uploads, methods=["GET"])
self.add_endpoint("/export_discussion", "export_discussion", self.export_discussion, methods=["GET"])
@ -630,6 +634,22 @@ class LoLLMsWebUI(LoLLMsAPPI):
fn = filename.split("/")[-1]
return send_from_directory(path, fn)
def serve_data(self, filename):
root_dir = os.getcwd()
path = os.path.join(root_dir, 'data/')+"/".join(filename.split("/")[:-1])
fn = filename.split("/")[-1]
return send_from_directory(path, fn)
def serve_uploads(self, filename):
root_dir = os.getcwd()
path = os.path.join(root_dir, 'uploads/')+"/".join(filename.split("/")[:-1])
fn = filename.split("/")[-1]
return send_from_directory(path, fn)
def export(self):
return jsonify(self.db.export_to_json())
@ -645,13 +665,22 @@ class LoLLMsWebUI(LoLLMsAPPI):
def stop_gen(self):
self.cancel_gen = True
self.process.cancel_generation()
return jsonify({"status": "ok"})
return jsonify({"status": True})
def add_reference_to_local_model(self):
data = request.get_json()
path = data["path"]
if path.exists():
self.conversation.config.reference_model(path)
return jsonify({"status": True})
else:
return jsonify({"status": True})
def send_file(self):
file = request.files['file']
Path("uploads").mkdir(exist_ok=True, parents=True)
file.save('uploads/' + file.filename)
return jsonify({"status": "ok"})
return jsonify({"status": True})
def rename(self):
data = request.get_json()
@ -699,26 +728,26 @@ class LoLLMsWebUI(LoLLMsAPPI):
new_message = request.args.get("message")
try:
self.current_discussion.update_message(discussion_id, new_message)
return jsonify({"status": "ok"})
return jsonify({"status": True})
except Exception as ex:
return jsonify({"status": "nok", "error":str(ex)})
return jsonify({"status": False, "error":str(ex)})
def message_rank_up(self):
discussion_id = request.args.get("id")
try:
new_rank = self.current_discussion.message_rank_up(discussion_id)
return jsonify({"status": "ok", "new_rank": new_rank})
return jsonify({"status": True, "new_rank": new_rank})
except Exception as ex:
return jsonify({"status": "nok", "error":str(ex)})
return jsonify({"status": False, "error":str(ex)})
def message_rank_down(self):
discussion_id = request.args.get("id")
try:
new_rank = self.current_discussion.message_rank_down(discussion_id)
return jsonify({"status": "ok", "new_rank": new_rank})
return jsonify({"status": True, "new_rank": new_rank})
except Exception as ex:
return jsonify({"status": "nok", "error":str(ex)})
return jsonify({"status": False, "error":str(ex)})
def delete_message(self):
discussion_id = request.args.get("id")
@ -941,9 +970,9 @@ def sync_cfg(default_config, config):
added_entries.append(key)
# Remove fields from config that don't exist in default_config
for key in list(config.keys()):
for key in list(config.config.keys()):
if key not in default_config:
del config[key]
del config.config[key]
removed_entries.append(key)
return config, added_entries, removed_entries
@ -951,7 +980,7 @@ def sync_cfg(default_config, config):
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Start the chatbot Flask app.")
parser.add_argument(
"-c", "--config", type=str, default="default", help="Sets the configuration file to be used."
"-c", "--config", type=str, default="local_config", help="Sets the configuration file to be used."
)
parser.add_argument(

View File

@ -1,5 +1,5 @@
# =================== Lord Of Large Language Models Configuration file ===========================
version: 5
version: 6
binding_name: llama_cpp_official
model_name: Wizard-Vicuna-7B-Uncensored.ggmlv3.q4_0.bin

View File

@ -110,7 +110,7 @@ This Flask server provides various endpoints to manage and interact with the cha
- "/stop_gen": GET request endpoint to stop the chatbot from generating responses.
```
{
"status": "ok"
"status": True
}
```

File diff suppressed because one or more lines are too long

63
web/dist/assets/index-8a386bea.js vendored Normal file

File diff suppressed because one or more lines are too long

1
web/dist/assets/index-8f4a78a8.css vendored Normal file

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>GPT4All - WEBUI</title>
<script type="module" crossorigin src="/assets/index-f5f472ed.js"></script>
<link rel="stylesheet" href="/assets/index-54621153.css">
<script type="module" crossorigin src="/assets/index-8a386bea.js"></script>
<link rel="stylesheet" href="/assets/index-8f4a78a8.css">
</head>
<body>
<div id="app"></div>

16
web/package-lock.json generated
View File

@ -15,6 +15,7 @@
"highlight.js": "^11.8.0",
"markdown-it": "^13.0.1",
"markdown-it-emoji": "^2.0.2",
"papaparse": "^5.4.1",
"socket.io-client": "^4.6.1",
"vue": "^3.2.47",
"vue-router": "^4.1.6"
@ -2352,6 +2353,11 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/papaparse": {
"version": "5.4.1",
"resolved": "https://registry.npmjs.org/papaparse/-/papaparse-5.4.1.tgz",
"integrity": "sha512-HipMsgJkZu8br23pW15uvo6sib6wne/4woLZPlFf3rpDyMe9ywEXUsuD7+6K9PRkJlVT51j/sCOYDKGGS3ZJrw=="
},
"node_modules/parent-module": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz",
@ -3076,14 +3082,14 @@
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw=="
},
"node_modules/vite": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/vite/-/vite-4.3.0.tgz",
"integrity": "sha512-JTGFgDh3dVxeGBpuQX04Up+JZmuG6wu9414Ei36vQzaEruY/M4K0AgwtuB2b4HaBgB7R8l+LHxjB0jcgz4d2qQ==",
"version": "4.3.9",
"resolved": "https://registry.npmjs.org/vite/-/vite-4.3.9.tgz",
"integrity": "sha512-qsTNZjO9NoJNW7KnOrgYwczm0WctJ8m/yqYAMAK9Lxt4SoySUfS5S8ia9K7JHpa3KEeMfyF8LoJ3c5NeBJy6pg==",
"dev": true,
"dependencies": {
"esbuild": "^0.17.5",
"postcss": "^8.4.21",
"rollup": "^3.20.2"
"postcss": "^8.4.23",
"rollup": "^3.21.0"
},
"bin": {
"vite": "bin/vite.js"

View File

@ -17,6 +17,7 @@
"highlight.js": "^11.8.0",
"markdown-it": "^13.0.1",
"markdown-it-emoji": "^2.0.2",
"papaparse": "^5.4.1",
"socket.io-client": "^4.6.1",
"vue": "^3.2.47",
"vue-router": "^4.1.6"

View File

@ -1,16 +1,60 @@
<template>
<div>
Help
<div class="container mx-auto p-4">
<h1 class="text-3xl font-bold mb-4">Help Page</h1>
<div class="mb-8">
<h2 class="text-2xl font-bold mb-2">Frequently Asked Questions</h2>
<ul class="list-disc pl-4">
<li v-for="(faq, index) in faqs" :key="index">
<h3 class="text-xl font-bold mb-1">{{ faq.question }}</h3>
<p class="mb-4">{{ faq.answer }}</p>
</li>
</ul>
</div>
<div>
<h2 class="text-2xl font-bold mb-2">Contact Us</h2>
<p class="mb-4">If you have any further questions or need assistance, feel free to reach out to us.</p>
<p>Discord link: <a href="https://discord.gg/C73K7hjy">https://discord.gg/C73K7hjy</a></p>
</div>
<div class="mt-8">
<h2 class="text-2xl font-bold mb-2">Credits</h2>
<p class="mb-4">This project is developed by <span class="font-bold">ParisNeo</span> With help from the community..</p>
<p class="mb-4"><span class="font-bold"><a href="https://github.com/ParisNeo/gpt4all-ui/graphs/contributors">Check out the full list of developers here and show them some love.</a></span></p>
<p>Check out the project on <a class="text-blue-500" :href="githubLink" target="_blank" rel="noopener noreferrer">GitHub</a>.</p>
</div>
</div>
</template>
<script>
export default {
setup () {
return {}
}
}
</script>
</template>
<script>
import Papa from 'papaparse'; // Import the Papa Parse library for CSV parsing
export default {
name: 'HelpPage',
data() {
return {
faqs: [], // Array to store the loaded FAQs
githubLink: 'https://github.com/ParisNeo/gpt4all-ui', // Replace with your project's GitHub link
};
},
mounted() {
this.loadFAQs(); // Call the method to load FAQs when the component is mounted
},
methods: {
loadFAQs() {
// Fetch and parse the CSV file
fetch('/data/faqs.csv')
.then((response) => response.text())
.then((csv) => {
const { data } = Papa.parse(csv, { header: true }); // Parse the CSV and extract data
this.faqs = data; // Assign the parsed data to the faqs array
})
.catch((error) => {
console.error('Error loading FAQs:', error);
});
},
},
};
</script>
<style scoped>
</style>

View File

@ -550,6 +550,7 @@ import PersonalityViewer from '@/components/PersonalityViewer.vue';
import PersonalityEntry from "../components/PersonalityEntry.vue";
import BindingEntry from "../components/BindingEntry.vue";
import socket from '@/services/websocket.js'
import defaultImgPlaceholder from "../assets/default_model.png"
axios.defaults.baseURL = import.meta.env.VITE_GPT4ALL_API_BASEURL
export default {
@ -1118,7 +1119,12 @@ export default {
if (!this.isMounted) {
return
}
return this.$refs.bindingZoo[this.$refs.bindingZoo.findIndex(item => item.binding.folder == this.configFile.binding_name)].$refs.imgElement.src
try{
return this.$refs.bindingZoo[this.$refs.bindingZoo.findIndex(item => item.binding.folder == this.configFile.binding_name)].$refs.imgElement.src
}
catch(error){
return defaultImgPlaceholder
}
},
imgModel() {
if (!this.isMounted) {
@ -1126,14 +1132,23 @@ export default {
}
console.log("Config file")
console.log(this.configFile)
return this.$refs.modelZoo[this.$refs.modelZoo.findIndex(item => item.title == this.configFile.model_name)].$refs.imgElement.src
try{
return this.$refs.modelZoo[this.$refs.modelZoo.findIndex(item => item.title == this.configFile.model_name)].$refs.imgElement.src
}
catch(error){
return defaultImgPlaceholder
}
},
imgPersonality() {
if (!this.isMounted) {
return
}
console.log(`ICON ${this.$refs.personalitiesZoo[this.$refs.personalitiesZoo.findIndex(item => item.personality.folder == this.configFile.personality_folder)].$refs.imgElement.src}`)
return this.$refs.personalitiesZoo[this.$refs.personalitiesZoo.findIndex(item => item.personality.folder == this.configFile.personality_folder)].$refs.imgElement.src
try{
return this.$refs.personalitiesZoo[this.$refs.personalitiesZoo.findIndex(item => item.personality.folder == this.configFile.personality_folder)].$refs.imgElement.src
}
catch(error){
return defaultImgPlaceholder
}
},
},