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/
|
backends/
|
||||||
|
!backends/gpt4all
|
||||||
!backends/llama_cpp
|
!backends/llama_cpp
|
||||||
!backends/gptj
|
!backends/gptj
|
||||||
!backends/__init__.py
|
!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):
|
def list_models(self):
|
||||||
models = self.backend.list_models(self.config)
|
if self.backend is not None:
|
||||||
return jsonify(models)
|
models = self.backend.list_models(self.config)
|
||||||
|
return jsonify(models)
|
||||||
|
else:
|
||||||
|
return jsonify([])
|
||||||
|
|
||||||
|
|
||||||
def list_personalities_languages(self):
|
def list_personalities_languages(self):
|
||||||
@ -707,7 +710,7 @@ class Gpt4AllWebUI(GPT4AllAPI):
|
|||||||
filename = model['filename']
|
filename = model['filename']
|
||||||
filesize = model['filesize']
|
filesize = model['filesize']
|
||||||
path = f'https://gpt4all.io/models/{filename}'
|
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({
|
models.append({
|
||||||
'title': model['filename'],
|
'title': model['filename'],
|
||||||
'icon': '/icons/default.png', # Replace with the path to the model icon
|
'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():
|
for key, value in default_config.items():
|
||||||
if key not in config:
|
if key not in config:
|
||||||
config[key] = value
|
config[key] = value
|
||||||
|
config["version"]=int(default_config["version"])
|
||||||
save_config(config, config_file_path)
|
save_config(config, config_file_path)
|
||||||
|
|
||||||
# Override values in config with command-line arguments
|
# Override values in config with command-line arguments
|
||||||
|
@ -7,8 +7,8 @@ n_threads: 8
|
|||||||
host: localhost
|
host: localhost
|
||||||
language: en-US
|
language: en-US
|
||||||
# Supported backends are llamacpp and gpt-j
|
# Supported backends are llamacpp and gpt-j
|
||||||
backend: llama_cpp
|
backend: gpt4all
|
||||||
model: gpt4all-lora-quantized-ggml.bin
|
model: null
|
||||||
n_predict: 1024
|
n_predict: 1024
|
||||||
nb_messages_to_remember: 5
|
nb_messages_to_remember: 5
|
||||||
personality_language: english
|
personality_language: english
|
||||||
|
@ -49,11 +49,21 @@ class GPT4AllAPI():
|
|||||||
# Select backend
|
# Select backend
|
||||||
self.BACKENDS_LIST = {f.stem:f for f in Path("backends").iterdir() if f.is_dir() and f.stem!="__pycache__"}
|
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
|
# generation status
|
||||||
self.generating=False
|
self.generating=False
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ markdown
|
|||||||
pyllamacpp==2.1.1
|
pyllamacpp==2.1.1
|
||||||
gpt4all-j
|
gpt4all-j
|
||||||
pygptj
|
pygptj
|
||||||
|
pygpt4all
|
||||||
--find-links https://download.pytorch.org/whl/cu117
|
--find-links https://download.pytorch.org/whl/cu117
|
||||||
torch==2.0.0
|
torch==2.0.0
|
||||||
torchvision
|
torchvision
|
||||||
|
@ -6,5 +6,6 @@ pyyaml
|
|||||||
markdown
|
markdown
|
||||||
pyllamacpp==2.0.0
|
pyllamacpp==2.0.0
|
||||||
gpt4all-j
|
gpt4all-j
|
||||||
|
pygpt4all
|
||||||
transformers
|
transformers
|
||||||
pyaipersonality>=0.0.11
|
pyaipersonality>=0.0.11
|
||||||
|
@ -1,43 +1,55 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="flex items-center p-4 hover:bg-primary-light rounded-lg mb-2 shadow-lg">
|
<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">
|
<div class="flex-shrink-0">
|
||||||
<i :class="`fas ${icon} text-xl`"></i>
|
<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>
|
</div>
|
||||||
</template>
|
<div class="flex-1">
|
||||||
|
<h3 class="font-bold text-lg">
|
||||||
<script>
|
<input
|
||||||
export default {
|
type="radio"
|
||||||
props: {
|
:checked="selected"
|
||||||
title: String,
|
:disabled="!isInstalled" <!-- Disable radio button if not installed -->
|
||||||
icon: String,
|
@change="handleSelection"
|
||||||
path: String,
|
/>
|
||||||
description: String,
|
{{ title }}
|
||||||
isInstalled: Boolean,
|
</h3>
|
||||||
onToggleInstall: Function,
|
<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: {
|
handleSelection() {
|
||||||
toggleInstall() {
|
if (this.isInstalled && !this.selected) { // Only emit event if installed and not already selected
|
||||||
this.onToggleInstall(this.isInstalled, this.path);
|
this.$emit('update:selected', true);
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
</script>
|
};
|
||||||
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user