mirror of
https://github.com/ParisNeo/lollms-webui.git
synced 2024-12-18 20:17:50 +00:00
added official python bindings
This commit is contained in:
parent
e85fce6823
commit
ef30c707d6
1
.gitignore
vendored
1
.gitignore
vendored
@ -162,6 +162,7 @@ extensions/
|
||||
|
||||
# backends
|
||||
backends/
|
||||
!backends/gpt4all
|
||||
!backends/llama_cpp
|
||||
!backends/gptj
|
||||
!backends/__init__.py
|
||||
|
BIN
ai_ethics/ParisNeo.png
Normal file
BIN
ai_ethics/ParisNeo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.1 KiB |
10
app.py
10
app.py
@ -375,8 +375,11 @@ class Gpt4AllWebUI(GPT4AllAPI):
|
||||
|
||||
|
||||
def list_models(self):
|
||||
models = self.backend.list_models(self.config)
|
||||
return jsonify(models)
|
||||
if self.backend is not None:
|
||||
models = self.backend.list_models(self.config)
|
||||
return jsonify(models)
|
||||
else:
|
||||
return jsonify([])
|
||||
|
||||
|
||||
def list_personalities_languages(self):
|
||||
@ -707,7 +710,7 @@ class Gpt4AllWebUI(GPT4AllAPI):
|
||||
filename = model['filename']
|
||||
filesize = model['filesize']
|
||||
path = f'https://gpt4all.io/models/{filename}'
|
||||
is_installed = Path(f'/models.llamacpp/{filename}').is_file()
|
||||
is_installed = Path(f'/models/{self.config["backend"]}/{filename}').is_file()
|
||||
models.append({
|
||||
'title': model['filename'],
|
||||
'icon': '/icons/default.png', # Replace with the path to the model icon
|
||||
@ -852,6 +855,7 @@ if __name__ == "__main__":
|
||||
for key, value in default_config.items():
|
||||
if key not in config:
|
||||
config[key] = value
|
||||
config["version"]=int(default_config["version"])
|
||||
save_config(config, config_file_path)
|
||||
|
||||
# Override values in config with command-line arguments
|
||||
|
@ -7,8 +7,8 @@ n_threads: 8
|
||||
host: localhost
|
||||
language: en-US
|
||||
# Supported backends are llamacpp and gpt-j
|
||||
backend: llama_cpp
|
||||
model: gpt4all-lora-quantized-ggml.bin
|
||||
backend: gpt4all
|
||||
model: null
|
||||
n_predict: 1024
|
||||
nb_messages_to_remember: 5
|
||||
personality_language: english
|
||||
|
@ -49,11 +49,21 @@ class GPT4AllAPI():
|
||||
# Select backend
|
||||
self.BACKENDS_LIST = {f.stem:f for f in Path("backends").iterdir() if f.is_dir() and f.stem!="__pycache__"}
|
||||
|
||||
self.backend =self.load_backend(self.BACKENDS_LIST[self.config["backend"]])
|
||||
if self.config["backend"] is None:
|
||||
self.backend = "gpt4all"
|
||||
else:
|
||||
try:
|
||||
self.backend = self.load_backend(self.BACKENDS_LIST[self.config["backend"]])
|
||||
# Build chatbot
|
||||
self.chatbot_bindings = self.create_chatbot()
|
||||
print("Chatbot created successfully")
|
||||
|
||||
except Exception:
|
||||
self.config["backend"] = None
|
||||
self.config["model"] = None
|
||||
self.backend = "gpt4all"
|
||||
print("No Models found, please select a backend and download a model for this tool to work")
|
||||
|
||||
# Build chatbot
|
||||
self.chatbot_bindings = self.create_chatbot()
|
||||
print("Chatbot created successfully")
|
||||
# generation status
|
||||
self.generating=False
|
||||
|
||||
|
@ -7,6 +7,7 @@ markdown
|
||||
pyllamacpp==2.1.1
|
||||
gpt4all-j
|
||||
pygptj
|
||||
pygpt4all
|
||||
--find-links https://download.pytorch.org/whl/cu117
|
||||
torch==2.0.0
|
||||
torchvision
|
||||
|
@ -6,5 +6,6 @@ pyyaml
|
||||
markdown
|
||||
pyllamacpp==2.0.0
|
||||
gpt4all-j
|
||||
pygpt4all
|
||||
transformers
|
||||
pyaipersonality>=0.0.11
|
||||
pyaipersonality>=0.0.11
|
||||
|
@ -1,43 +1,55 @@
|
||||
<template>
|
||||
<div class="flex items-center p-4 hover:bg-primary-light rounded-lg mb-2 shadow-lg">
|
||||
|
||||
|
||||
|
||||
<div class="flex-shrink-0">
|
||||
<i :class="`fas ${icon} text-xl`"></i>
|
||||
</div>
|
||||
<div class="flex-1">
|
||||
<h3 class="font-bold text-lg">{{ title }}</h3>
|
||||
<p class="opacity-80">{{ description }}</p>
|
||||
</div>
|
||||
<div class="flex-shrink-0">
|
||||
<button
|
||||
class="px-4 py-2 rounded-md text-white font-bold transition-colors duration-300"
|
||||
:class="[isInstalled ? 'bg-red-500 hover:bg-red-600' : 'bg-green-500 hover:bg-green-600']"
|
||||
@click="toggleInstall"
|
||||
>
|
||||
{{ isInstalled ? 'Uninstall' : 'Install' }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="flex items-center p-4 hover:bg-primary-light rounded-lg mb-2 shadow-lg"
|
||||
:class="{ 'bg-primary-light': selected }"
|
||||
>
|
||||
<div class="flex-shrink-0">
|
||||
<i :class="`fas ${icon} text-xl`"></i>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
title: String,
|
||||
icon: String,
|
||||
path: String,
|
||||
description: String,
|
||||
isInstalled: Boolean,
|
||||
onToggleInstall: Function,
|
||||
<div class="flex-1">
|
||||
<h3 class="font-bold text-lg">
|
||||
<input
|
||||
type="radio"
|
||||
:checked="selected"
|
||||
:disabled="!isInstalled" <!-- Disable radio button if not installed -->
|
||||
@change="handleSelection"
|
||||
/>
|
||||
{{ title }}
|
||||
</h3>
|
||||
<p class="opacity-80">{{ description }}</p>
|
||||
</div>
|
||||
<div class="flex-shrink-0">
|
||||
<button
|
||||
class="px-4 py-2 rounded-md text-white font-bold transition-colors duration-300"
|
||||
:class="[isInstalled ? 'bg-red-500 hover:bg-red-600' : 'bg-green-500 hover:bg-green-600']"
|
||||
@click="toggleInstall"
|
||||
>
|
||||
{{ isInstalled ? 'Uninstall' : 'Install' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
title: String,
|
||||
icon: String,
|
||||
path: String,
|
||||
description: String,
|
||||
isInstalled: Boolean,
|
||||
onToggleInstall: Function,
|
||||
selected: Boolean // Use a boolean selected prop
|
||||
},
|
||||
methods: {
|
||||
toggleInstall() {
|
||||
this.onToggleInstall(this.isInstalled, this.path);
|
||||
},
|
||||
methods: {
|
||||
toggleInstall() {
|
||||
this.onToggleInstall(this.isInstalled, this.path);
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
handleSelection() {
|
||||
if (this.isInstalled && !this.selected) { // Only emit event if installed and not already selected
|
||||
this.$emit('update:selected', true);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user