feat: add focus schema

This commit is contained in:
Yuta Saito 2026-01-08 12:17:14 +09:00
parent 565a622cf9
commit 3af9bab6a5
2 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,33 @@
"""Schema definitions for Focus export data."""
from __future__ import annotations
import polars as pl
FOCUS_NORMALIZED_SCHEMA = pl.Schema(
{
"usage_date": pl.Datetime(time_unit="us"),
"team_id": pl.String,
"team_alias": pl.String,
"user_id": pl.String,
"user_email": pl.String,
"api_key_alias": pl.String,
"model": pl.String,
"model_group": pl.String,
"custom_llm_provider": pl.String,
"prompt_tokens": pl.Int64,
"completion_tokens": pl.Int64,
"total_tokens": pl.Int64,
"spend": pl.Float64,
"cache_creation_input_tokens": pl.Int64,
"cache_read_input_tokens": pl.Int64,
"api_requests": pl.Int64,
"successful_requests": pl.Int64,
"failed_requests": pl.Int64,
"created_at": pl.Datetime(time_unit="us"),
"updated_at": pl.Datetime(time_unit="us"),
}
)
__all__ = ["FOCUS_NORMALIZED_SCHEMA"]

View File

@ -4,10 +4,14 @@ from __future__ import annotations
import polars as pl
from .schema import FOCUS_NORMALIZED_SCHEMA
class FocusTransformer:
"""Transforms LiteLLM DB rows into Focus-compatible schema."""
schema = FOCUS_NORMALIZED_SCHEMA
def transform(self, frame: pl.DataFrame) -> pl.DataFrame:
"""Return a normalized frame expected by downstream serializers."""
raise NotImplementedError