ModelUsageActivityRecord#
Build extensions, choose hooks, and manage request-scoped state. See the guide.
- class zett_agent.extensions.usage_activity.ModelUsageActivityRecord(*, session_id, request_id, provider, model, occurred_at, input_tokens, output_tokens, cache_read_tokens, cache_write_tokens, reasoning_tokens, ttft_any_ns=None, ttft_content_ns=None, first_chunk=None, first_content_chunk=None)[源代码]#
One completed model request recorded for activity visualization.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- 参数:
session_id (str)
request_id (str | None)
provider (str | None)
model (str | None)
occurred_at (datetime)
input_tokens (Annotated[int, Ge(ge=0)])
output_tokens (Annotated[int, Ge(ge=0)])
cache_read_tokens (Annotated[int, Ge(ge=0)])
cache_write_tokens (Annotated[int, Ge(ge=0)])
reasoning_tokens (Annotated[int, Ge(ge=0)])
ttft_any_ns (Annotated[int | None, Ge(ge=0)])
ttft_content_ns (Annotated[int | None, Ge(ge=0)])
first_chunk (str | None)
first_content_chunk (str | None)
- ttft_any_ns: int | None#
Nanoseconds from the request starting to the first streamed delta of any kind; None when the runtime observed no delta.
- ttft_content_ns: int | None#
Nanoseconds from the request starting to the first answer-content delta; None when the stream carried no answer content.
- first_chunk: str | None#
First streamed delta of any kind, clipped by the runtime before the call.
- first_content_chunk: str | None#
First streamed answer-content delta, clipped the same way.
- property total_tokens: int#
Return the tokens represented by this request.
Fields#
session_id(required)See the typed model signature for this field.
request_id(required)See the typed model signature for this field.
provider(required)See the typed model signature for this field.
model(required)See the typed model signature for this field.
occurred_at(required)See the typed model signature for this field.
input_tokens(required)See the typed model signature for this field.
output_tokens(required)See the typed model signature for this field.
cache_read_tokens(required)See the typed model signature for this field.
cache_write_tokens(required)See the typed model signature for this field.
reasoning_tokens(required)See the typed model signature for this field.
ttft_any_ns(optional)See the typed model signature for this field.
ttft_content_ns(optional)See the typed model signature for this field.
first_chunk(optional)See the typed model signature for this field.
first_content_chunk(optional)See the typed model signature for this field.