From ef30c707d65b587d72bdc35e7d9b3cd206015f00 Mon Sep 17 00:00:00 2001 From: ParisNeo Date: Thu, 11 May 2023 15:09:35 +0200 Subject: [PATCH] added official python bindings --- .gitignore | 1 + ai_ethics/ParisNeo.png | Bin 0 -> 8291 bytes app.py | 10 +++- configs/default.yaml | 4 +- pyGpt4All/api.py | 18 ++++-- requirements.txt | 1 + requirements_dev.txt | 3 +- web/src/components/ModelEntry.vue | 92 +++++++++++++++++------------- 8 files changed, 79 insertions(+), 50 deletions(-) create mode 100644 ai_ethics/ParisNeo.png diff --git a/.gitignore b/.gitignore index 42e6a261..9ea4ca2e 100644 --- a/.gitignore +++ b/.gitignore @@ -162,6 +162,7 @@ extensions/ # backends backends/ +!backends/gpt4all !backends/llama_cpp !backends/gptj !backends/__init__.py diff --git a/ai_ethics/ParisNeo.png b/ai_ethics/ParisNeo.png new file mode 100644 index 0000000000000000000000000000000000000000..64ac502895919d4626d86f80be754ba3438a8643 GIT binary patch literal 8291 zcmV-pAe`TcP)Px#1ZP1_K>z@;j|==^1poj7^iWJxMgRZ*`}Xwx^y~fQ%>L@s|J}C!;=}*mx$^Gs z+Ry-+`GKMrKYKafPHLod0t*%OH5E(SX^Faag&RKn3$Wx!^PFs-SqSIiHC{+ z00A{QHiCnMtE;X5;kwGi!;+4WT2)gB3=9MnFX-IVb#!+qEH42JBDkcJ+{36gL{fo- zjK;~(WMgR|JWqFQV|sdf+1cG2A|Z!~j@#ALF(e`-B_x@hqSMmU&CJk4Lqx^I%Kh%& zr=p(z@#L14mZG7h;nT%FJV4vNrJtRhUQ|t>jelulTR%8548B*1Dto>e}hbvE}6IzObR~=jHU`&;Sf9+}z`^u(L2aKp!3;etv@8%DFl= zJZo%o1REc9fRCG{t+ckhs+EDu-sS)mIhUHEg^-&70UjA4GC)L6jE<9pi(# zLrPQ7ub0fx+Jby|RasW0n2#SRCk7ibkA7_?B`!-zMd7=m_0F*p4ibKCUlA)n(a+f$ z2MAMFU&y(&LQr0Hc!M@m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tGghQ^)=x@A?trz`n&6ICxO;lfeG`=)J+kBxkxF2OA0CJ+!J@=fU0j$&2 z4HmQJo~FL5EBEE@oZQ^tewvccs7ZhS<;%t?BtZ8N`_O2G z`x~cREd5%q*`n#XKv&n~=jV?+mvjOwNK0FG9A-L0e0)i#`&Y(u@k4r@zPN0FEsCHj zjWjD#f#dO=|pyTJTSqOvXL|dTiu2?JbZ<=p(t|fBqB^`XBu#A|fIpA|fIp hA|fIp5<-N9{XhO#3=NqL(YF8q002ovPDHLkV1m4@1L6Px literal 0 HcmV?d00001 diff --git a/app.py b/app.py index f691d656..5f0f9759 100644 --- a/app.py +++ b/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 diff --git a/configs/default.yaml b/configs/default.yaml index 82618ad3..6c12b3d4 100644 --- a/configs/default.yaml +++ b/configs/default.yaml @@ -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 diff --git a/pyGpt4All/api.py b/pyGpt4All/api.py index fc6a562d..722eb05c 100644 --- a/pyGpt4All/api.py +++ b/pyGpt4All/api.py @@ -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 diff --git a/requirements.txt b/requirements.txt index b41832cd..bcf86e94 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 diff --git a/requirements_dev.txt b/requirements_dev.txt index af48d59c..6cffea8b 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -6,5 +6,6 @@ pyyaml markdown pyllamacpp==2.0.0 gpt4all-j +pygpt4all transformers -pyaipersonality>=0.0.11 \ No newline at end of file +pyaipersonality>=0.0.11 diff --git a/web/src/components/ModelEntry.vue b/web/src/components/ModelEntry.vue index 488cb001..41d6066e 100644 --- a/web/src/components/ModelEntry.vue +++ b/web/src/components/ModelEntry.vue @@ -1,43 +1,55 @@ - - - \ No newline at end of file + handleSelection() { + if (this.isInstalled && !this.selected) { // Only emit event if installed and not already selected + this.$emit('update:selected', true); + } + } + } +}; +