Buckets:

download
raw
1.32 kB
"""Unified response types for LLM providers."""
from dataclasses import dataclass, field
from typing import Any
@dataclass
class ToolCall:
"""Represents a tool call from the LLM."""
id: str
name: str
arguments: dict[str, Any]
@dataclass
class ToolResult:
"""Represents the result of a tool execution."""
tool_call_id: str
content: str | list[dict[str, Any]]
is_error: bool = False
@dataclass
class Usage:
"""Token usage statistics."""
input_tokens: int = 0
output_tokens: int = 0
@property
def total_tokens(self) -> int:
"""Total tokens used."""
return self.input_tokens + self.output_tokens
@dataclass
class LLMResponse:
"""Unified response from any LLM provider."""
text: str | None = None
tool_calls: list[ToolCall] = field(default_factory=list)
stop_reason: str | None = None
usage: dict[str, int] | Usage = field(default_factory=dict)
raw_response: Any = None
@property
def has_tool_calls(self) -> bool:
"""Check if response contains tool calls."""
return len(self.tool_calls) > 0
@property
def is_complete(self) -> bool:
"""Check if the response indicates completion."""
return self.stop_reason in ("end_turn", "stop", "STOP", None) and not self.has_tool_calls

Xet Storage Details

Size:
1.32 kB
·
Xet hash:
53fc5113918c373c08a5c786388af1ccade9ffd5161fddd0401375ce1f8c0105

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.