From 1f0148ab835b7add7e6656b66362238283fb5086 Mon Sep 17 00:00:00 2001 From: Saifeddine ALOUI Date: Sun, 15 Sep 2024 16:30:06 +0200 Subject: [PATCH] Enhanced tools --- app.py | 2 ++ endpoints/libraries/lollms_client_js.js | 13 ++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app.py b/app.py index 72d52642..30730386 100644 --- a/app.py +++ b/app.py @@ -13,6 +13,8 @@ import threading import time import sys from typing import List, Tuple +import os +os.environ["KMP_DUPLICATE_LIB_OK"]="TRUE" expected_ascii_colors_version = "0.4.2" print(f"Checking ascii_colors ({expected_ascii_colors_version}) ...", end="", flush=True) if not PackageManager.check_package_installed_with_version("ascii_colors", expected_ascii_colors_version): diff --git a/endpoints/libraries/lollms_client_js.js b/endpoints/libraries/lollms_client_js.js index 89d6ad91..0d497cd8 100644 --- a/endpoints/libraries/lollms_client_js.js +++ b/endpoints/libraries/lollms_client_js.js @@ -108,6 +108,9 @@ class LollmsClient { console.log('Settings updated:', settings); } + separatorTemplate(){ + return this.template.separator_template; + } system_message(){ return this.template.start_header_id_template+this.template.system_message_template+this.template.end_header_id_template } @@ -560,8 +563,8 @@ async generateCode(prompt, images = [], { } = {}){ let response; const systemHeader = this.custom_message("Generation infos"); - const codeInstructions = "Generated code must be put inside the adequate markdown code tag. Use this template:\n```language name\nCode\n```\nMake sure only a single code tag is generated at each dialogue turn."; - const fullPrompt = systemHeader + codeInstructions + this.separatorTemplate + prompt; + const codeInstructions = "Generated code must be put inside the adequate markdown code tag. Use this template:\n```language name\nCode\n```\nMake sure only a single code tag is generated at each dialogue turn.\n"; + const fullPrompt = systemHeader + codeInstructions + this.separatorTemplate() + prompt; if (images.length > 0) { response = await this.generate_with_images(fullPrompt, images, { @@ -592,7 +595,7 @@ async generateCode(prompt, images = [], { code = codes[0].content.split('\n').slice(0, -1).join('\n'); while (!codes[0].is_complete) { console.warn("The AI did not finish the code, let's ask it to continue") - const continuePrompt = prompt + code + this.userFullHeader + "continue the code. Rewrite last line and continue the code." + this.separatorTemplate + this.aiFullHeader; + const continuePrompt = prompt + code + this.userFullHeader + "continue the code. Rewrite last line and continue the code." + this.separatorTemplate() + this.aiFullHeader; response = await this.generate(fullPrompt, { n_predict: n_predict, temperature: temperature, @@ -635,7 +638,7 @@ async generateCodes(prompt, images = [], { let response; const systemHeader = this.custom_message("Generation infos"); const codeInstructions = "Generated code must be put inside the adequate markdown code tag. Use this template:\n```language name\nCode\n```\n"; - const fullPrompt = systemHeader + codeInstructions + this.separatorTemplate + prompt; + const fullPrompt = systemHeader + codeInstructions + this.separatorTemplate() + prompt; if (images.length > 0) { response = await this.generate_with_images(fullPrompt, images, { @@ -668,7 +671,7 @@ async generateCodes(prompt, images = [], { while (!currentCode.is_complete) { console.warn("The AI did not finish the code, let's ask it to continue"); - const continuePrompt = prompt + codeContent + this.userFullHeader + "continue the code. Rewrite last line and continue the code." + this.separatorTemplate + this.aiFullHeader; + const continuePrompt = prompt + codeContent + this.userFullHeader + "continue the code. Rewrite last line and continue the code." + this.separatorTemplate() + this.aiFullHeader; response = await this.generate(continuePrompt, { n_predict,