Spaces:
Paused
Paused
| import json | |
| import os | |
| from datetime import datetime | |
| from pathlib import Path | |
| import uuid | |
| from typing import Literal, Dict | |
| import logging | |
| from .provider_urls import get_provider_endpoint | |
| def log_request_to_console(url: str, headers: dict, client_info: tuple, request_data: dict): | |
| """ | |
| Logs a concise, single-line summary of an incoming request to the console. | |
| """ | |
| time_str = datetime.now().strftime("%H:%M") | |
| model_full = request_data.get("model", "N/A") | |
| provider = "N/A" | |
| model_name = model_full | |
| endpoint_url = "N/A" | |
| if '/' in model_full: | |
| parts = model_full.split('/', 1) | |
| provider = parts[0] | |
| model_name = parts[1] | |
| # Use the helper function to get the full endpoint URL | |
| endpoint_url = get_provider_endpoint(provider, model_name, url) or "N/A" | |
| log_message = f"{time_str} - {client_info[0]}:{client_info[1]} - provider: {provider}, model: {model_name} - {endpoint_url}" | |
| logging.info(log_message) | |