๐พ Record¶
trulens_eval.schema.record.Record
¶
Bases: SerialModel
, Hashable
The record of a single main method call.
Note
This class will be renamed to Trace
in the future.
Attributes¶
cost
class-attribute
instance-attribute
¶
Costs associated with the record.
ts
class-attribute
instance-attribute
¶
Timestamp of last update.
This is usually set whenever a record is changed in any way.
main_input
class-attribute
instance-attribute
¶
The app's main input.
main_output
class-attribute
instance-attribute
¶
The app's main output if there was no error.
main_error
class-attribute
instance-attribute
¶
The app's main error if there was an error.
calls
class-attribute
instance-attribute
¶
calls: List[RecordAppCall] = []
The collection of calls recorded.
Note that these can be converted into a json structure with the same paths
as the app that generated this record via layout_calls_as_app
.
feedback_and_future_results
class-attribute
instance-attribute
¶
feedback_and_future_results: Optional[List[Tuple[FeedbackDefinition, Future[FeedbackResult]]]] = Field(None, exclude=True)
Map of feedbacks to the futures for of their results.
These are only filled for records that were just produced. This will not
be filled in when read from database. Also, will not fill in when using
FeedbackMode.DEFERRED
.
feedback_results
class-attribute
instance-attribute
¶
feedback_results: Optional[List[Future[FeedbackResult]]] = Field(None, exclude=True)
Only the futures part of the above for backwards compatibility.
Functions¶
wait_for_feedback_results
¶
wait_for_feedback_results() -> Dict[FeedbackDefinition, FeedbackResult]
Wait for feedback results to finish.
RETURNS | DESCRIPTION |
---|---|
Dict[FeedbackDefinition, FeedbackResult]
|
A mapping of feedback functions to their results. |
layout_calls_as_app
¶
layout_calls_as_app() -> Munch
Layout the calls in this record into the structure that follows that of the app that created this record.
This uses the paths stored in each RecordAppCall which are paths into the app.
Note: We cannot create a validated AppDefinition class (or subclass) object here as the layout of records differ in these ways:
-
Records do not include anything that is not an instrumented method hence have most of the structure of a app missing.
-
Records have RecordAppCall as their leafs where method definitions would be in the AppDefinition structure.
trulens_eval.schema.record.RecordAppCall
¶
Bases: SerialModel
Info regarding each instrumented method call.
Attributes¶
stack
instance-attribute
¶
stack: List[RecordAppCallMethod]
Call stack but only containing paths of instrumented apps/other objects.
rets
class-attribute
instance-attribute
¶
Returns of the instrumented method if successful.
Sometimes this is a dict, sometimes a sequence, and sometimes a base value.
error
class-attribute
instance-attribute
¶
Error message if call raised exception.
perf
class-attribute
instance-attribute
¶
Timestamps tracking entrance and exit of the instrumented method.
Functions¶
trulens_eval.schema.record.RecordAppCallMethod
¶
trulens_eval.schema.base.Cost
¶
Bases: SerialModel
, BaseModel
Costs associated with some call or set of calls.
Attributes¶
n_successful_requests
class-attribute
instance-attribute
¶
n_successful_requests: int = 0
Number of successful requests.
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.