From 6e3ddab42ebf4d397c2337dcbeee9c483f7d5b35 Mon Sep 17 00:00:00 2001 From: Cyberes Date: Mon, 21 Aug 2023 23:07:12 -0600 Subject: [PATCH] fix relative paths for db path --- requirements.txt | 3 ++- server.py | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 560f840..b309450 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,4 +3,5 @@ flask_cors pyyaml flask_caching requests -tiktoken \ No newline at end of file +tiktoken +gunicorn \ No newline at end of file diff --git a/server.py b/server.py index 2d6b00a..349f9a0 100644 --- a/server.py +++ b/server.py @@ -14,11 +14,13 @@ from llm_server.routes.cache import cache from llm_server.routes.helpers.http import cache_control from llm_server.routes.v1 import bp +script_path = os.path.dirname(os.path.realpath(__file__)) + config_path_environ = os.getenv("CONFIG_PATH") if config_path_environ: config_path = config_path_environ else: - config_path = Path(os.path.dirname(os.path.realpath(__file__)), 'config', 'config.yml') + config_path = Path(script_path, 'config', 'config.yml') default_vars = {'mode': 'oobabooga', 'log_prompts': False, 'database_path': './proxy-server.db', 'auth_required': False} required_vars = [] @@ -30,6 +32,10 @@ if not success: opts.backend_url = config['backend_url'].strip('/') +# Resolve relative directory to the directory of the script +if config['database_path'].startswith('./'): + config['database_path'] = resolve_path(script_path, config['database_path'].strip('./')) + opts.database_path = resolve_path(config['database_path']) init_db(opts.database_path)