from pathlib import Path
from pydantic import BaseModel
from typing import Protocol
from openai.types.responses.response_usage import ResponseUsage
from openai.types.realtime.realtime_response_usage import RealtimeResponseUsage
from openai.types.realtime.conversation_item_input_audio_transcription_completed_event import UsageTranscriptTextUsageTokens


UsageTypes = ResponseUsage | RealtimeResponseUsage | UsageTranscriptTextUsageTokens


class Writer(Protocol):
    """Writers must accept a str name or file path."""
    def __init__(self, name: str | Path): ...

    def initialize(self, pricing: dict[str, float]) -> None: ...

    def write(self, model: str, result: str, usage: UsageTypes, costs: BaseModel): ...

    def close(self): ...

