Update app.py
Browse files
app.py
CHANGED
|
@@ -158,12 +158,14 @@ def handle_request():
|
|
| 158 |
messages = body.get('messages')
|
| 159 |
stream = body.get('stream', False)
|
| 160 |
if not model or not messages or len(messages) == 0:
|
|
|
|
| 161 |
return jsonify({"error": "Bad Request: Missing required fields"}), 400
|
| 162 |
|
| 163 |
# 映射 model
|
| 164 |
if model in MODEL_MAPPING:
|
| 165 |
mapped_model = MODEL_MAPPING[model]['mapping']
|
| 166 |
else:
|
|
|
|
| 167 |
return jsonify({"error": f"Model '{model}' not found"}), 400
|
| 168 |
|
| 169 |
prompt = messages[-1]['content']
|
|
@@ -172,6 +174,7 @@ def handle_request():
|
|
| 172 |
auth_header = request.headers.get('Authorization')
|
| 173 |
random_token = get_random_token(auth_header)
|
| 174 |
if not random_token:
|
|
|
|
| 175 |
return jsonify({"error": "Unauthorized: Invalid or missing Authorization header"}), 401
|
| 176 |
|
| 177 |
if use_original:
|
|
|
|
| 158 |
messages = body.get('messages')
|
| 159 |
stream = body.get('stream', False)
|
| 160 |
if not model or not messages or len(messages) == 0:
|
| 161 |
+
app.logger.info(f"POST /ai/v1/chat/completions - Status: 400 - Bad Request - Missing required fields")
|
| 162 |
return jsonify({"error": "Bad Request: Missing required fields"}), 400
|
| 163 |
|
| 164 |
# 映射 model
|
| 165 |
if model in MODEL_MAPPING:
|
| 166 |
mapped_model = MODEL_MAPPING[model]['mapping']
|
| 167 |
else:
|
| 168 |
+
app.logger.info(f"POST /ai/v1/chat/completions - Status: 400 - Bad Request - Model '{model}' not found")
|
| 169 |
return jsonify({"error": f"Model '{model}' not found"}), 400
|
| 170 |
|
| 171 |
prompt = messages[-1]['content']
|
|
|
|
| 174 |
auth_header = request.headers.get('Authorization')
|
| 175 |
random_token = get_random_token(auth_header)
|
| 176 |
if not random_token:
|
| 177 |
+
app.logger.info(f"POST /ai/v1/chat/completions - Status: 401 - Unauthorized - Invalid or missing Authorization header")
|
| 178 |
return jsonify({"error": "Unauthorized: Invalid or missing Authorization header"}), 401
|
| 179 |
|
| 180 |
if use_original:
|