diff --git a/config/config.yml b/config/config.yml index b40e7bb..5316904 100644 --- a/config/config.yml +++ b/config/config.yml @@ -10,6 +10,14 @@ token_limit: 7777 backend_url: https://10.0.0.86:8083 +## STATS ## + +# Display the total_proompts item on the stats screen. +show_num_prompts: true + +# Display the uptime item on the stats screen. +show_uptime: true + # Load the number of prompts from the database to display on the stats page. load_num_prompts: true diff --git a/llm_server/config.py b/llm_server/config.py index fb192df..4d718ae 100644 --- a/llm_server/config.py +++ b/llm_server/config.py @@ -1,5 +1,17 @@ import yaml +config_default_vars = { + 'log_prompts': False, + 'database_path': './proxy-server.db', + 'auth_required': False, + 'frontend_api_client': '', + 'verify_ssl': True, + 'load_num_prompts': False, + 'show_num_prompts': True, + 'show_uptime': True, +} +config_required_vars = ['token_limit', 'concurrent_gens', 'mode'] + class ConfigLoader: """ diff --git a/llm_server/opts.py b/llm_server/opts.py index b4893dc..8bcbdce 100644 --- a/llm_server/opts.py +++ b/llm_server/opts.py @@ -11,3 +11,5 @@ log_prompts = False frontend_api_client = '' http_host = None verify_ssl = True +show_num_prompts = True +show_uptime = True diff --git a/llm_server/routes/v1/proxy.py b/llm_server/routes/v1/proxy.py index 6d954b5..39f2115 100644 --- a/llm_server/routes/v1/proxy.py +++ b/llm_server/routes/v1/proxy.py @@ -34,8 +34,8 @@ def get_stats(): 'stats': { 'prompts_in_queue': proompters_in_queue, 'proompters_1_min': SemaphoreCheckerThread.proompters_1_min, - 'total_proompts': stats.get_total_proompts(), - 'uptime': int((datetime.now() - stats.server_start_time).total_seconds()), + 'total_proompts': stats.get_total_proompts() if opts.show_num_prompts else None, + 'uptime': int((datetime.now() - stats.server_start_time).total_seconds()) if opts.show_uptime else None, 'average_generation_elapsed_sec': average_generation_time, }, 'online': online, diff --git a/server.py b/server.py index 1cbeeaa..f15f66e 100644 --- a/server.py +++ b/server.py @@ -3,10 +3,11 @@ import sys from pathlib import Path from threading import Thread +import config from flask import Flask, jsonify from llm_server import opts -from llm_server.config import ConfigLoader +from llm_server.config import ConfigLoader, config_default_vars, config_required_vars from llm_server.database import get_number_of_rows, init_db from llm_server.helpers import resolve_path from llm_server.routes.cache import cache, redis @@ -23,16 +24,12 @@ if config_path_environ: else: config_path = Path(script_path, 'config', 'config.yml') -default_vars = {'mode': 'oobabooga', 'log_prompts': False, 'database_path': './proxy-server.db', 'auth_required': False, 'concurrent_gens': 3, 'frontend_api_client': '', 'verify_ssl': True, 'load_num_prompts': False} -required_vars = ['token_limit'] -config_loader = ConfigLoader(config_path, default_vars, required_vars) +config_loader = ConfigLoader(config_path, config_default_vars, config_required_vars) success, config, msg = config_loader.load_config() if not success: print('Failed to load config:', msg) sys.exit(1) -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('./')) @@ -48,6 +45,9 @@ opts.log_prompts = config['log_prompts'] opts.concurrent_gens = config['concurrent_gens'] opts.frontend_api_client = config['frontend_api_client'] opts.context_size = config['token_limit'] +opts.show_num_prompts = config['show_num_prompts'] +opts.show_uptime = config['show_uptime'] +opts.backend_url = config['backend_url'].strip('/') opts.verify_ssl = config['verify_ssl'] if not opts.verify_ssl: