|
32 | 32 | # Setup logging |
33 | 33 | logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') |
34 | 34 | logger = logging.getLogger(__name__) |
| 35 | +logging_levels = { |
| 36 | + "notset": logging.NOTSET, |
| 37 | + "debug": logging.DEBUG, |
| 38 | + "info": logging.INFO, |
| 39 | + "warning": logging.WARNING, |
| 40 | + "error": logging.ERROR, |
| 41 | + "critical": logging.CRITICAL, |
| 42 | +} |
35 | 43 |
|
36 | 44 | # Initialize Flask app |
37 | 45 | app = Flask(__name__) |
|
78 | 86 | 'optillm_api_key': '', |
79 | 87 | 'return_full_response': False, |
80 | 88 | 'port': 8000, |
| 89 | + 'log': 'info', |
81 | 90 | } |
82 | 91 |
|
83 | 92 | # List of known approaches |
@@ -370,6 +379,7 @@ def parse_args(): |
370 | 379 | ("--n", "OPTILLM_N", int, 1, "Number of final responses to be returned"), |
371 | 380 | ("--return-full-response", "OPTILLM_RETURN_FULL_RESPONSE", bool, False, "Return the full response including the CoT with <thinking> tags"), |
372 | 381 | ("--port", "OPTILLM_PORT", int, 8000, "Specify the port to run the proxy"), |
| 382 | + ("--log", "OPTILLM_LOG", str, "info", "Specify the logging level", list(logging_levels.keys())) |
373 | 383 | ] |
374 | 384 |
|
375 | 385 | for arg, env, type_, default, help_text, *extra in args_env: |
@@ -415,6 +425,12 @@ def main(): |
415 | 425 | server_config.update(vars(args)) |
416 | 426 |
|
417 | 427 | port = server_config['port'] |
| 428 | + |
| 429 | + # Set logging level from user request |
| 430 | + logging_level = server_config['log'] |
| 431 | + if logging_level in logging_levels.keys(): |
| 432 | + logger.setLevel(logging_levels[logging_level]) |
| 433 | + |
418 | 434 | logger.info(f"Starting server with approach: {server_config['approach']}") |
419 | 435 | server_config_clean = server_config.copy() |
420 | 436 | if server_config_clean['optillm_api_key']: |
|
0 commit comments