Spaces:
Paused
Paused
Download backend/application/services/request_trace_service.py from data-llm-hub/tensorwall: direct link, hf CLI and curl.
- Browser
- Download file 1.46 kB
-
https://huggingface.co/spaces/data-llm-hub/tensorwall/resolve/main/backend/application/services/request_trace_service.py
- Command line
-
hf download hf://spaces/data-llm-hub/tensorwall/backend/application/services/request_trace_service.py
-
curl -L -o request_trace_service.py https://huggingface.co/spaces/data-llm-hub/tensorwall/resolve/main/backend/application/services/request_trace_service.py
1.46 kB
| """Request Trace Service - Stub for legacy compatibility. | |
| This module provides request tracing functionality. | |
| """ | |
| from typing import Optional, Dict, Any, List | |
| import logging | |
| logger = logging.getLogger(__name__) | |
| class RequestTraceService: | |
| """Service for tracing LLM requests.""" | |
| async def create_trace( | |
| self, | |
| request_id: str, | |
| app_id: str, | |
| feature: str, | |
| environment: str, | |
| model: str, | |
| messages: List[Dict[str, Any]], | |
| **kwargs, | |
| ) -> None: | |
| """Create a new request trace.""" | |
| logger.debug(f"Trace created: {request_id}") | |
| async def update_decision( | |
| self, | |
| request_id: str, | |
| decision: str, | |
| reasons: Optional[List[str]] = None, | |
| **kwargs, | |
| ) -> None: | |
| """Update trace with decision.""" | |
| logger.debug(f"Trace decision updated: {request_id} -> {decision}") | |
| async def finalize_trace( | |
| self, | |
| request_id: str, | |
| status: str, | |
| response: Optional[Dict[str, Any]] = None, | |
| error: Optional[str] = None, | |
| tokens_input: Optional[int] = None, | |
| tokens_output: Optional[int] = None, | |
| cost_usd: Optional[float] = None, | |
| latency_ms: Optional[float] = None, | |
| **kwargs, | |
| ) -> None: | |
| """Finalize the request trace.""" | |
| logger.debug(f"Trace finalized: {request_id} -> {status}") | |
| # Singleton | |
| request_trace_service = RequestTraceService() | |