From 9ea54166eb61a54b9516f7960a71a31f47367fa3 Mon Sep 17 00:00:00 2001 From: NikitaKiriy Date: Fri, 25 Oct 2024 12:35:29 -0400 Subject: [PATCH] support user defined models --- hindsight_server/config.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/hindsight_server/config.py b/hindsight_server/config.py index 3f03cc0..564602a 100644 --- a/hindsight_server/config.py +++ b/hindsight_server/config.py @@ -1,5 +1,6 @@ import os import platform +import json from pathlib import Path BASE_DIR = Path(os.path.dirname(os.path.abspath(__file__))) @@ -7,13 +8,16 @@ HOME = Path.home() HINDSIGHT_SERVER_DIR = HOME / ".hindsight_server" + DATA_DIR = HINDSIGHT_SERVER_DIR / "data" +USER_SETTINGS_FILE = HINDSIGHT_SERVER_DIR / "user_settings.json" +API_KEY_FILE = HINDSIGHT_SERVER_DIR / "secret_api_key.txt" + SCREENSHOTS_TMP_DIR = DATA_DIR / "raw_screenshots_tmp" RAW_SCREENSHOTS_DIR = DATA_DIR / "raw_screenshots" SERVER_LOG_FILE = DATA_DIR / "hindsight_server.log" ANDROID_IDENTIFIERS_ALIAS_FILE = DATA_DIR / "android_identifiers.json" -API_KEY_FILE = HINDSIGHT_SERVER_DIR / "secret_api_key.txt" if os.path.exists(API_KEY_FILE): with open(API_KEY_FILE, 'r') as infile: SECRET_API_KEY = infile.read().strip() @@ -32,3 +36,11 @@ https://github.com/taylorai/mlx_embedding_models/blob/main/src/mlx_embedding_models/registry.py """ MLX_EMBDEDDING_MODEL = "bge-large" + +if os.path.isfile(USER_SETTINGS_FILE): + with open(USER_SETTINGS_FILE) as user_file: + user_settings = json.load(user_file) + print('Applying user settings to configuration:', user_settings) + LLM_MODEL_NAME = user_settings['LLM_MODEL_NAME'] +else: + print('Using default configuration')