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_classes class-attribute instance-attribute
n_classes: int = 0

Number of class scores 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_cortext_guardrails_tokens class-attribute instance-attribute
n_cortext_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.

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