From bfd2cfe48df5013120d38649b856c0938f3fd07b Mon Sep 17 00:00:00 2001 From: saloui Date: Tue, 2 May 2023 11:02:59 +0200 Subject: [PATCH] Moving to new version of pyllamacpp --- add_backend.bat | 55 ++++++++++++++++++++++++++++++++++ app.py | 1 + backends/llama_cpp/__init__.py | 4 +-- static/js/main.js | 1 + 4 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 add_backend.bat diff --git a/add_backend.bat b/add_backend.bat new file mode 100644 index 00000000..096bd676 --- /dev/null +++ b/add_backend.bat @@ -0,0 +1,55 @@ +@echo off +setlocal enabledelayedexpansion + +REM Clone the repository to a tmp folder +set "REPO_URL=https://github.com/ParisNeo/PyAIPersonality.git" +set "TMP_FOLDER=%temp%\PyAIPersonality" +git clone %REPO_URL% %TMP_FOLDER% + +REM List the available languages and prompt user to select one +set "LANGUAGES_FOLDER=%TMP_FOLDER%\personalities_zoo" +set "LANGUAGE_INDEX=0" +for /d %%d in ("%LANGUAGES_FOLDER%\*") do ( + set /a "LANGUAGE_INDEX+=1" + set "LANGUAGES[!LANGUAGE_INDEX!]=%%~nxd" + echo !LANGUAGE_INDEX!. %%~nxd +) +set /p "SELECTED_LANGUAGE=Enter the number of the desired language: " +set "LANGUAGE_FOLDER=%LANGUAGES_FOLDER%\!LANGUAGES[%SELECTED_LANGUAGE%]!" + +REM List the available categories and prompt user to select one +set "CATEGORIES_FOLDER=%LANGUAGE_FOLDER%" +set "CATEGORY_INDEX=0" +for /d %%d in ("%CATEGORIES_FOLDER%\*") do ( + set /a "CATEGORY_INDEX+=1" + set "CATEGORIES[!CATEGORY_INDEX!]=%%~nxd" + echo !CATEGORY_INDEX!. %%~nxd +) +set /p "SELECTED_CATEGORY=Enter the number of the desired category: " +set "CATEGORY_FOLDER=%CATEGORIES_FOLDER%\!CATEGORIES[%SELECTED_CATEGORY%]!" + +REM List the available personalities and prompt user to select one +set "PERSONALITIES_FOLDER=%CATEGORY_FOLDER%" +set "PERSONALITY_INDEX=0" +for /d %%d in ("%PERSONALITIES_FOLDER%\*") do ( + set /a "PERSONALITY_INDEX+=1" + set "PERSONALITIES[!PERSONALITY_INDEX!]=%%~nxd" + echo !PERSONALITY_INDEX!. %%~nxd +) +set /p "SELECTED_PERSONALITY=Enter the number of the desired personality: " +set "PERSONALITY_FOLDER=%PERSONALITIES_FOLDER%\!PERSONALITIES[%SELECTED_PERSONALITY%]!" + +REM Copy the selected personality folder to personalities/language/category folder +set "OUTPUT_FOLDER=%CD%\personalities\!LANGUAGES[%SELECTED_LANGUAGE%]!\!CATEGORIES[%SELECTED_CATEGORY%]!\!PERSONALITIES[%SELECTED_PERSONALITY%]!" +if not exist "%OUTPUT_FOLDER%" mkdir "%OUTPUT_FOLDER%" +xcopy /e /y "%PERSONALITY_FOLDER%" "%OUTPUT_FOLDER%" + +REM cleaning +if exist "./tmp" ( +echo Cleaning tmp folder +rd /s /q "./tmp" +) +REM Remove the tmp folder +rd /s /q "%TMP_FOLDER%" +echo Done +pause \ No newline at end of file diff --git a/app.py b/app.py index 5dfd2cc7..c301d2a5 100644 --- a/app.py +++ b/app.py @@ -342,6 +342,7 @@ class Gpt4AllWebUI(GPT4AllAPI): def stop_gen(self): self.cancel_gen = True + print("Stop generation received") return jsonify({"status": "ok"}) def rename(self): diff --git a/backends/llama_cpp/__init__.py b/backends/llama_cpp/__init__.py index ac60c3c9..20adace2 100644 --- a/backends/llama_cpp/__init__.py +++ b/backends/llama_cpp/__init__.py @@ -30,8 +30,8 @@ class LLAMACPP(GPTBackend): super().__init__(config, False) self.model = Model( - ggml_model=f"./models/llama_cpp/{self.config['model']}", - prompt_context="", prompt_prefix="", prompt_suffix="", anti_prompts= [], + model_path=f"./models/llama_cpp/{self.config['model']}", + prompt_context="", prompt_prefix="", prompt_suffix="", n_ctx=self.config['ctx_size'], seed=self.config['seed'], ) diff --git a/static/js/main.js b/static/js/main.js index 0d4d58af..2aa975e8 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -81,6 +81,7 @@ function update_main(){ .then(response => response.json()) .then(data => { console.log(data); + socket.disconnect() }); })