allow hiding of more variables
This commit is contained in:
parent
11a0b6541f
commit
3317bd5f1a
|
@ -10,6 +10,14 @@ token_limit: 7777
|
||||||
|
|
||||||
backend_url: https://10.0.0.86:8083
|
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 the number of prompts from the database to display on the stats page.
|
||||||
load_num_prompts: true
|
load_num_prompts: true
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,17 @@
|
||||||
import yaml
|
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:
|
class ConfigLoader:
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -11,3 +11,5 @@ log_prompts = False
|
||||||
frontend_api_client = ''
|
frontend_api_client = ''
|
||||||
http_host = None
|
http_host = None
|
||||||
verify_ssl = True
|
verify_ssl = True
|
||||||
|
show_num_prompts = True
|
||||||
|
show_uptime = True
|
||||||
|
|
|
@ -34,8 +34,8 @@ def get_stats():
|
||||||
'stats': {
|
'stats': {
|
||||||
'prompts_in_queue': proompters_in_queue,
|
'prompts_in_queue': proompters_in_queue,
|
||||||
'proompters_1_min': SemaphoreCheckerThread.proompters_1_min,
|
'proompters_1_min': SemaphoreCheckerThread.proompters_1_min,
|
||||||
'total_proompts': stats.get_total_proompts(),
|
'total_proompts': stats.get_total_proompts() if opts.show_num_prompts else None,
|
||||||
'uptime': int((datetime.now() - stats.server_start_time).total_seconds()),
|
'uptime': int((datetime.now() - stats.server_start_time).total_seconds()) if opts.show_uptime else None,
|
||||||
'average_generation_elapsed_sec': average_generation_time,
|
'average_generation_elapsed_sec': average_generation_time,
|
||||||
},
|
},
|
||||||
'online': online,
|
'online': online,
|
||||||
|
|
12
server.py
12
server.py
|
@ -3,10 +3,11 @@ import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
|
||||||
|
import config
|
||||||
from flask import Flask, jsonify
|
from flask import Flask, jsonify
|
||||||
|
|
||||||
from llm_server import opts
|
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.database import get_number_of_rows, init_db
|
||||||
from llm_server.helpers import resolve_path
|
from llm_server.helpers import resolve_path
|
||||||
from llm_server.routes.cache import cache, redis
|
from llm_server.routes.cache import cache, redis
|
||||||
|
@ -23,16 +24,12 @@ if config_path_environ:
|
||||||
else:
|
else:
|
||||||
config_path = Path(script_path, '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, 'concurrent_gens': 3, 'frontend_api_client': '', 'verify_ssl': True, 'load_num_prompts': False}
|
config_loader = ConfigLoader(config_path, config_default_vars, config_required_vars)
|
||||||
required_vars = ['token_limit']
|
|
||||||
config_loader = ConfigLoader(config_path, default_vars, required_vars)
|
|
||||||
success, config, msg = config_loader.load_config()
|
success, config, msg = config_loader.load_config()
|
||||||
if not success:
|
if not success:
|
||||||
print('Failed to load config:', msg)
|
print('Failed to load config:', msg)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
opts.backend_url = config['backend_url'].strip('/')
|
|
||||||
|
|
||||||
# Resolve relative directory to the directory of the script
|
# Resolve relative directory to the directory of the script
|
||||||
if config['database_path'].startswith('./'):
|
if config['database_path'].startswith('./'):
|
||||||
config['database_path'] = resolve_path(script_path, config['database_path'].strip('./'))
|
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.concurrent_gens = config['concurrent_gens']
|
||||||
opts.frontend_api_client = config['frontend_api_client']
|
opts.frontend_api_client = config['frontend_api_client']
|
||||||
opts.context_size = config['token_limit']
|
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']
|
opts.verify_ssl = config['verify_ssl']
|
||||||
if not opts.verify_ssl:
|
if not opts.verify_ssl:
|
||||||
|
|
Reference in New Issue