Skip to content

Commit d4b1fe2

Browse files
authored
Merge pull request #48 from jovanwongzixi/cli-logging-flag
Add cli log flag
2 parents 35c40a1 + c89b635 commit d4b1fe2

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

optillm.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@
3232
# Setup logging
3333
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
3434
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+
}
3543

3644
# Initialize Flask app
3745
app = Flask(__name__)
@@ -78,6 +86,7 @@
7886
'optillm_api_key': '',
7987
'return_full_response': False,
8088
'port': 8000,
89+
'log': 'info',
8190
}
8291

8392
# List of known approaches
@@ -370,6 +379,7 @@ def parse_args():
370379
("--n", "OPTILLM_N", int, 1, "Number of final responses to be returned"),
371380
("--return-full-response", "OPTILLM_RETURN_FULL_RESPONSE", bool, False, "Return the full response including the CoT with <thinking> tags"),
372381
("--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()))
373383
]
374384

375385
for arg, env, type_, default, help_text, *extra in args_env:
@@ -415,6 +425,12 @@ def main():
415425
server_config.update(vars(args))
416426

417427
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+
418434
logger.info(f"Starting server with approach: {server_config['approach']}")
419435
server_config_clean = server_config.copy()
420436
if server_config_clean['optillm_api_key']:

0 commit comments

Comments
 (0)