Skip to content

trulens.core.schema.base

trulens.core.schema.base

Common/shared serializable classes.

Attributes

MAX_DILL_SIZE module-attribute

MAX_DILL_SIZE: int = 1024 * 1024

Max size in bytes of pickled objects.

Classes

Cost

Bases: SerialModel, BaseModel

Costs associated with some call or set of calls.

Attributes
n_requests class-attribute instance-attribute
n_requests: int = 0

Number of requests.

n_successful_requests class-attribute instance-attribute
n_successful_requests: int = 0

Number of successful requests.

n_completion_requests class-attribute instance-attribute
n_completion_requests: int = 0

Number of completion requests.

n_classification_requests class-attribute instance-attribute
n_classification_requests: int = 0

Number of classification requests.

n_classes class-attribute instance-attribute
n_classes: int = 0

Number of class scores retrieved.

n_embedding_requests class-attribute instance-attribute
n_embedding_requests: int = 0

Number of embedding requests.

n_embeddings class-attribute instance-attribute
n_embeddings: int = 0

Number of embeddings retrieved.

n_tokens class-attribute instance-attribute
n_tokens: int = 0

Total tokens processed.

n_stream_chunks class-attribute instance-attribute
n_stream_chunks: int = 0

In streaming mode, number of chunks produced.

n_prompt_tokens class-attribute instance-attribute
n_prompt_tokens: int = 0

Number of prompt tokens supplied.

n_completion_tokens class-attribute instance-attribute
n_completion_tokens: int = 0

Number of completion tokens generated.

n_cortex_guardrails_tokens class-attribute instance-attribute
n_cortex_guardrails_tokens: int = 0

Number of guardrails tokens generated. i.e. available in Cortex endpoint.

cost class-attribute instance-attribute
cost: float = 0.0

Cost in [cost_currency].

Functions
__rich_repr__
__rich_repr__() -> Result

Requirement for pretty printing using the rich package.

Perf

Bases: SerialModel, BaseModel

Performance information.

Presently only the start and end times, and thus latency.

Attributes
start_time instance-attribute
start_time: datetime

Datetime before the recorded call.

end_time instance-attribute
end_time: datetime

Datetime after the recorded call.

latency property
latency

Latency in seconds.

start_ns_timestamp property
start_ns_timestamp: int

EXPERIMENTAL: otel-tracing

Start time in number of nanoseconds since the epoch.

end_ns_timestamp property
end_ns_timestamp: int

EXPERIMENTAL: otel-tracing

End time in number of nanoseconds since the epoch.

Functions
__rich_repr__
__rich_repr__() -> Result

Requirement for pretty printing using the rich package.

min staticmethod
min()

Zero-length span with start and end times at the minimum datetime.

now staticmethod
now(latency: Optional[timedelta] = None) -> Perf

Create a Perf instance starting now and ending now plus latency.

PARAMETER DESCRIPTION
latency

Latency in seconds. If given, end time will be now plus latency. Otherwise end time will be a minimal interval plus start_time.

TYPE: Optional[timedelta] DEFAULT: None

of_ns_timestamps staticmethod
of_ns_timestamps(
    start_ns_timestamp: int,
    end_ns_timestamp: Optional[int] = None,
) -> Perf

EXPERIMENTAL: otel-tracing

Create a Perf instance from start and end times in nanoseconds since the epoch.