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.
To increment immediately when a request is made.
n_successful_requests
class-attribute
instance-attribute
¶
n_successful_requests: int = 0
Number of successful requests.
To increment only after a response is processed and it indicates success.
n_completion_requests
class-attribute
instance-attribute
¶
n_completion_requests: int = 0
Number of completion requests.
To increment immediately when a completion request is made.
n_classification_requests
class-attribute
instance-attribute
¶
n_classification_requests: int = 0
Number of classification requests.
To increment immediately when a classification request is made.
n_classes
class-attribute
instance-attribute
¶
n_classes: int = 0
Number of class scores retrieved.
To increment for each class in a successful classification response.
n_embedding_requests
class-attribute
instance-attribute
¶
n_embedding_requests: int = 0
Number of embedding requests.
To increment immediately when an embedding request is made.
n_embeddings
class-attribute
instance-attribute
¶
n_embeddings: int = 0
Number of embeddings retrieved.
To increment for each embedding vector returned by an embedding request.
n_tokens
class-attribute
instance-attribute
¶
n_tokens: int = 0
Total tokens processed.
To increment by the number of input(prompt) and output tokens in completion requests. While the input part of this could be incremented upon a request, the actual count is not easy to determine due to tokenizer variations and instead is usually seen in the response. Also, we want to count only tokens for successful requests that incur a cost to the user.
n_stream_chunks
class-attribute
instance-attribute
¶
n_stream_chunks: int = 0
In streaming mode, number of chunks produced.
To increment for each chunk in a streaming response. This does not need to wait for completion of the responses.
n_prompt_tokens
class-attribute
instance-attribute
¶
n_prompt_tokens: int = 0
Number of prompt tokens supplied.
To increment by the number of tokens in the prompt of a completion request. This is visible in the response though and should only count successful requests.
n_completion_tokens
class-attribute
instance-attribute
¶
n_completion_tokens: int = 0
Number of completion tokens generated.
To increment by the number of tokens in the completion of a completion request.
n_cortex_guardrails_tokens
class-attribute
instance-attribute
¶
n_cortex_guardrails_tokens: int = 0
Number of guardrails tokens generated. This is only available for requests instrumented by the Cortex endpoint.
cost
class-attribute
instance-attribute
¶
cost: float = 0.0
Cost in [cost_currency].
This may not always be available or accurate.
Functions¶
Perf
¶
Bases: SerialModel
, BaseModel
Performance information.
Presently only the start and end times, and thus latency.
Attributes¶
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.