Skip to content

Commit 7beeb4f

Browse files
committed
Update optillm.py
1 parent 0f907aa commit 7beeb4f

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

optillm.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,6 @@ def proxy():
696696
default_client, api_key = get_config()
697697

698698
operation, approaches, model = parse_combined_approach(model, known_approaches, plugin_approaches)
699-
logger.info(f'Using approach(es) {approaches}, operation {operation}, with model {model}')
700699

701700
# Start conversation logging if enabled
702701
request_id = None
@@ -713,6 +712,12 @@ def proxy():
713712
model=model
714713
)
715714

715+
# Log approach and request start with ID for terminal monitoring
716+
request_id_str = f' [Request: {request_id}]' if request_id else ''
717+
logger.info(f'Using approach(es) {approaches}, operation {operation}, with model {model}{request_id_str}')
718+
if request_id:
719+
logger.info(f'Request {request_id}: Starting processing')
720+
716721
if bearer_token != "" and bearer_token.startswith("sk-"):
717722
api_key = bearer_token
718723
if base_url != "":
@@ -763,8 +768,12 @@ def proxy():
763768
conversation_logger.finalize_conversation(request_id)
764769

765770
if stream:
771+
if request_id:
772+
logger.info(f'Request {request_id}: Completed (streaming response)')
766773
return Response(generate_streaming_response(extract_contents(result), model), content_type='text/event-stream')
767774
else :
775+
if request_id:
776+
logger.info(f'Request {request_id}: Completed')
768777
return jsonify(result), 200
769778

770779
elif operation == 'AND' or operation == 'OR':
@@ -780,7 +789,8 @@ def proxy():
780789
conversation_logger.log_error(request_id, str(e))
781790
conversation_logger.finalize_conversation(request_id)
782791

783-
logger.error(f"Error processing request: {str(e)}")
792+
request_id_str = f' {request_id}' if request_id else ''
793+
logger.error(f"Error processing request{request_id_str}: {str(e)}")
784794
return jsonify({"error": str(e)}), 500
785795

786796
# Convert tagged conversation to messages format if needed
@@ -844,6 +854,8 @@ def proxy():
844854
conversation_logger.finalize_conversation(request_id)
845855

846856
logger.debug(f'API response: {response_data}')
857+
if request_id:
858+
logger.info(f'Request {request_id}: Completed')
847859
return jsonify(response_data), 200
848860

849861
@app.route('/v1/models', methods=['GET'])

0 commit comments

Comments
 (0)