Add debug logging for autoselect request validation

- Log raw request body before validation to diagnose 422 errors
- Log request headers and path for debugging
- Make Message content field more flexible with List type
- Helps identify validation issues in incoming requests
parent b560e363
...@@ -28,7 +28,7 @@ from typing import Dict, List, Optional, Union ...@@ -28,7 +28,7 @@ from typing import Dict, List, Optional, Union
class Message(BaseModel): class Message(BaseModel):
role: str role: str
content: Union[str, List[Dict]] content: Union[str, List[Dict], List]
class ChatCompletionRequest(BaseModel): class ChatCompletionRequest(BaseModel):
model: str model: str
......
...@@ -230,8 +230,16 @@ async def autoselect_chat_completions(request: Request, body: ChatCompletionRequ ...@@ -230,8 +230,16 @@ async def autoselect_chat_completions(request: Request, body: ChatCompletionRequ
"""Handle chat completions for autoselect using model name to select autoselect configuration""" """Handle chat completions for autoselect using model name to select autoselect configuration"""
logger.info(f"=== AUTOSELECT CHAT COMPLETION REQUEST START ===") logger.info(f"=== AUTOSELECT CHAT COMPLETION REQUEST START ===")
logger.info(f"Request path: {request.url.path}") logger.info(f"Request path: {request.url.path}")
logger.info(f"Model requested: {body.model}")
logger.info(f"Request headers: {dict(request.headers)}") logger.info(f"Request headers: {dict(request.headers)}")
# Log raw request body for debugging
try:
raw_body = await request.body()
logger.info(f"Raw request body: {raw_body.decode('utf-8')}")
except Exception as e:
logger.error(f"Error reading raw body: {str(e)}")
logger.info(f"Model requested: {body.model}")
logger.info(f"Request body: {body}") logger.info(f"Request body: {body}")
logger.info(f"Available autoselect: {list(config.autoselect.keys())}") logger.info(f"Available autoselect: {list(config.autoselect.keys())}")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment