Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions optillm.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@
# Setup logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)
logging_levels = {
"notset": logging.NOTSET,
"debug": logging.DEBUG,
"info": logging.INFO,
"warning": logging.WARNING,
"error": logging.ERROR,
"critical": logging.CRITICAL,
}

# Initialize Flask app
app = Flask(__name__)
Expand Down Expand Up @@ -78,6 +86,7 @@
'optillm_api_key': '',
'return_full_response': False,
'port': 8000,
'log': 'info',
}

# List of known approaches
Expand Down Expand Up @@ -370,6 +379,7 @@ def parse_args():
("--n", "OPTILLM_N", int, 1, "Number of final responses to be returned"),
("--return-full-response", "OPTILLM_RETURN_FULL_RESPONSE", bool, False, "Return the full response including the CoT with <thinking> tags"),
("--port", "OPTILLM_PORT", int, 8000, "Specify the port to run the proxy"),
("--log", "OPTILLM_LOG", str, "info", "Specify the logging level", list(logging_levels.keys()))
]

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

port = server_config['port']

# Set logging level from user request
logging_level = server_config['log']
if logging_level in logging_levels.keys():
logger.setLevel(logging_levels[logging_level])

logger.info(f"Starting server with approach: {server_config['approach']}")
server_config_clean = server_config.copy()
if server_config_clean['optillm_api_key']:
Expand Down