From 1b7ee2a9fb9f8317048a9f4d0b4ec37b973accf9 Mon Sep 17 00:00:00 2001 From: Bohan Cheng <47214785+cbh778899@users.noreply.github.com> Date: Sun, 25 Aug 2024 11:55:18 +1000 Subject: [PATCH] fix setup & inference with plugin bugs (#67) * add LOAD_DEFAULT_DATASET and DEFAULT_DATASET_NAME to .env.production on setup Signed-off-by: cbh778899 * fix bugs crashes app when use system_instruction in plugin Signed-off-by: cbh778899 --------- Signed-off-by: cbh778899 --- .env.production | 4 +++- actions/inference.js | 2 +- setup/setup.c | 4 +++- setup/setup_types.h | 4 +++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.env.production b/.env.production index 8e7122f..b34e715 100644 --- a/.env.production +++ b/.env.production @@ -1,9 +1,11 @@ ALLOW_ORIGIN="*" STATIC_API_KEY_ENABLED=0 -ENABLE_HTTPS=0 ENABLE_PLUGIN=0 +ENABLE_HTTPS=0 HTTPS_KEY_PATH="*/privkey.pem" HTTPS_CERT_PATH="*/cert.pem" HTTPS_CA_PATH="*/chain.pem" SYSTEM_INSTRUCTION="*" +LOAD_DEFAULT_DATASET=0 +DEFAULT_DATASET_NAME="production_dataset" AVAILABLE_APIS="ALL" \ No newline at end of file diff --git a/actions/inference.js b/actions/inference.js index bb8e7ac..abc40e1 100644 --- a/actions/inference.js +++ b/actions/inference.js @@ -164,7 +164,7 @@ export async function chatCompletion(req, res) { request_body.prompt = formatOpenAIContext(value); break; case "system_instruction": - messages.push(value); + messages.push({role:"system", content: value}); break; case "normal": default: break; diff --git a/setup/setup.c b/setup/setup.c index 7c8c540..8a1a3be 100644 --- a/setup/setup.c +++ b/setup/setup.c @@ -641,12 +641,14 @@ void saveSettings(int show_message) { fprintf(f, ENV_PRODUCTION_FILE, allow_origin_name, static_api_key_enabled, - https_enabled, plugin_enabled, + https_enabled, https_cert_path_container, https_privkey_name, https_cert_path_container, https_cert_name, https_cert_path_container, https_ca_name, system_instruction, + default_dataset_enabled, + default_dataset_name, api_enabled_str ); fclose(f); diff --git a/setup/setup_types.h b/setup/setup_types.h index 41c6951..8befe64 100644 --- a/setup/setup_types.h +++ b/setup/setup_types.h @@ -584,12 +584,14 @@ #define ENV_PRODUCTION_FILE \ "ALLOW_ORIGIN=\"%s\"\n"\ "STATIC_API_KEY_ENABLED=%d\n"\ -"ENABLE_HTTPS=%d\n"\ "ENABLE_PLUGIN=%d\n"\ +"ENABLE_HTTPS=%d\n"\ "HTTPS_KEY_PATH=\"%s/%s\"\n"\ "HTTPS_CERT_PATH=\"%s/%s\"\n"\ "HTTPS_CA_PATH=\"%s/%s\"\n"\ "SYSTEM_INSTRUCTION=\"%s\"\n"\ +"LOAD_DEFAULT_DATASET=%d\n"\ +"DEFAULT_DATASET_NAME=\"%s\"\n"\ "AVAILABLE_APIS=\"%s\"" #define AVAILABLE_APIS_FORMAT "%d%d%d%d.%d%d.%d.%d%d.%d"