mirror of
https://github.com/ParisNeo/lollms-webui.git
synced 2025-04-13 05:42:59 +00:00
upgraded code
This commit is contained in:
parent
ab5e3d9f85
commit
4295bd1d5c
11
app.py
11
app.py
@ -109,7 +109,7 @@ class Gpt4AllWebUI(GPT4AllAPI):
|
||||
self.add_endpoint("/", "", self.index, methods=["GET"])
|
||||
self.add_endpoint("/<path:filename>", "serve_static", self.serve_static, methods=["GET"])
|
||||
self.add_endpoint("/personalities/<path:filename>", "serve_personalities", self.serve_personalities, methods=["GET"])
|
||||
|
||||
|
||||
|
||||
self.add_endpoint("/export_discussion", "export_discussion", self.export_discussion, methods=["GET"])
|
||||
self.add_endpoint("/export", "export", self.export, methods=["GET"])
|
||||
@ -778,8 +778,13 @@ class Gpt4AllWebUI(GPT4AllAPI):
|
||||
|
||||
|
||||
def get_available_models(self):
|
||||
response = requests.get(f'https://gpt4all.io/models/models.json')
|
||||
model_list = response.json()
|
||||
"""Get the available models
|
||||
|
||||
Returns:
|
||||
_type_: _description_
|
||||
"""
|
||||
|
||||
model_list = self.backend.get_available_models()
|
||||
|
||||
models = []
|
||||
for model in model_list:
|
||||
|
@ -11,6 +11,7 @@ from pathlib import Path
|
||||
from typing import Callable
|
||||
from pygpt4all import GPT4All as Model
|
||||
from pyGpt4All.backend import GPTBackend
|
||||
import yaml
|
||||
|
||||
__author__ = "parisneo"
|
||||
__github__ = "https://github.com/nomic-ai/gpt4all-ui"
|
||||
@ -21,6 +22,7 @@ backend_name = "GPT4ALL"
|
||||
|
||||
class GPT4ALL(GPTBackend):
|
||||
file_extension='*.bin'
|
||||
|
||||
def __init__(self, config:dict) -> None:
|
||||
"""Builds a GPT4ALL backend
|
||||
|
||||
@ -67,4 +69,15 @@ class GPT4ALL(GPTBackend):
|
||||
if not new_text_callback(tok):
|
||||
return
|
||||
except Exception as ex:
|
||||
print(ex)
|
||||
print(ex)
|
||||
|
||||
@staticmethod
|
||||
def get_available_models():
|
||||
# Create the file path relative to the child class's directory
|
||||
backend_path = Path(__file__).parent
|
||||
file_path = backend_path/"models.yaml"
|
||||
|
||||
with open(file_path, 'r') as file:
|
||||
yaml_data = yaml.safe_load(file)
|
||||
|
||||
return yaml_data
|
@ -11,6 +11,7 @@ from pathlib import Path
|
||||
from typing import Callable
|
||||
from pyllamacpp.model import Model
|
||||
from pyGpt4All.backend import GPTBackend
|
||||
import yaml
|
||||
|
||||
__author__ = "parisneo"
|
||||
__github__ = "https://github.com/nomic-ai/gpt4all-ui"
|
||||
@ -67,4 +68,15 @@ class LLAMACPP(GPTBackend):
|
||||
if not new_text_callback(tok):
|
||||
return
|
||||
except Exception as ex:
|
||||
print(ex)
|
||||
print(ex)
|
||||
|
||||
@staticmethod
|
||||
def get_available_models():
|
||||
# Create the file path relative to the child class's directory
|
||||
backend_path = Path(__file__).parent
|
||||
file_path = backend_path/"models.yaml"
|
||||
|
||||
with open(file_path, 'r') as file:
|
||||
yaml_data = yaml.safe_load(file)
|
||||
|
||||
return yaml_data
|
@ -7,7 +7,7 @@ n_threads: 8
|
||||
host: localhost
|
||||
language: en-US
|
||||
# Supported backends are llamacpp and gpt-j
|
||||
backend: gpt4all
|
||||
backend: llamacpp
|
||||
model: null
|
||||
n_predict: 1024
|
||||
nb_messages_to_remember: 5
|
||||
|
@ -9,6 +9,9 @@
|
||||
######
|
||||
from pathlib import Path
|
||||
from typing import Callable
|
||||
import inspect
|
||||
import yaml
|
||||
import sys
|
||||
|
||||
__author__ = "parisneo"
|
||||
__github__ = "https://github.com/nomic-ai/gpt4all-ui"
|
||||
@ -18,6 +21,7 @@ __license__ = "Apache 2.0"
|
||||
|
||||
class GPTBackend:
|
||||
file_extension='*.bin'
|
||||
backend_path = Path(__file__).parent
|
||||
def __init__(self, config:dict, inline:bool) -> None:
|
||||
self.config = config
|
||||
self.inline = inline
|
||||
@ -45,3 +49,13 @@ class GPTBackend:
|
||||
"""
|
||||
models_dir = Path('./models')/config["backend"] # replace with the actual path to the models folder
|
||||
return [f.name for f in models_dir.glob(GPTBackend.file_extension)]
|
||||
@staticmethod
|
||||
def get_available_models():
|
||||
# Create the file path relative to the child class's directory
|
||||
backend_path = Path(__file__).parent
|
||||
file_path = backend_path/"models.yaml"
|
||||
|
||||
with open(file_path, 'r') as file:
|
||||
yaml_data = yaml.safe_load(file)
|
||||
|
||||
return yaml_data
|
@ -450,13 +450,17 @@ export default {
|
||||
axios.post('/update_setting', obj).then((res) => {
|
||||
if (res) {
|
||||
if (next !== undefined) {
|
||||
next()
|
||||
next(res)
|
||||
}
|
||||
return res.data;
|
||||
}
|
||||
})
|
||||
.catch(error => { return { 'status': false } });
|
||||
},
|
||||
update_backend(value) {
|
||||
console.log("Upgrading backend")
|
||||
res = this.update_setting('backend', value, (res)=>{console.log("Backend changed"); })
|
||||
},
|
||||
save_configuration() {
|
||||
this.showConfirmation = false
|
||||
axios.post('/save_settings', {})
|
||||
@ -502,13 +506,7 @@ export default {
|
||||
}
|
||||
});
|
||||
},
|
||||
update_backend(value) {
|
||||
res = update_setting('backend', value)
|
||||
if (res.status) {
|
||||
console.log("Backend changed")
|
||||
}
|
||||
|
||||
},
|
||||
async api_get_req(endpoint) {
|
||||
try {
|
||||
const res = await axios.get("/" + endpoint);
|
||||
|
Loading…
x
Reference in New Issue
Block a user