Spaces:
Paused
Paused
File size: 1,458 Bytes
f3bcb28 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | """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()
|