Skip to main content

History and Logs

classes.history.iteration

Iteration Objects

logs()

@property
def logs() -> Stack[str]

Returns the logs from this iteration as a stack.

tokens_consumed()

@property
def tokens_consumed() -> Optional[int]

Returns the total number of tokens consumed during this iteration.

prompt_tokens_consumed()

@property
def prompt_tokens_consumed() -> Optional[int]

Returns the number of prompt/input tokens consumed during this iteration.

completion_tokens_consumed()

@property
def completion_tokens_consumed() -> Optional[int]

Returns the number of completion/output tokens consumed during this iteration.

raw_output()

@property
def raw_output() -> Optional[str]

The exact output from the LLM.

parsed_output()

@property
def parsed_output() -> Optional[Union[str, Dict]]

The output from the LLM after undergoing parsing but before validation.

validation_response()

@property
def validation_response() -> Optional[Union[ReAsk, str, Dict]]

The response from a single stage of validation.

Validation response is the output of a single stage of validation and could be a combination of valid output and reasks. Note that a Guard may run validation multiple times if reasks occur. To access the final output after all steps of validation are completed, check out Call.guarded_output."

validation_output()

@property
@deprecated(
"""'Iteration.validation_output' is deprecated and will be removed in \
versions 0.5.0 and beyond. Use 'validation_response' instead.""")
def validation_output() -> Optional[Union[ReAsk, str, Dict]]

The output from the validation process.

Could be a combination of valid output and ReAsks

guarded_output()

@property
def guarded_output() -> Optional[Union[str, Dict]]

Any valid values after undergoing validation.

Some values in the validated output may be "fixed" values that were corrected during validation. This property may be a partial structure if field level reasks occur.

validated_output()

@property
@deprecated(
"""'Iteration.validated_output' is deprecated and will be removed in \
versions 0.5.0 and beyond. Use 'guarded_output' instead.""")
def validated_output() -> Optional[Union[str, Dict]]

The valid output from the LLM after undergoing validation.

Could be only a partial structure if field level reasks occur. Could contain fixed values.

reasks()

@property
def reasks() -> Sequence[ReAsk]

Reasks generated during validation.

These would be incorporated into the prompt or the next LLM call.

validator_logs()

@property
def validator_logs() -> List[ValidatorLogs]

The results of each individual validation performed on the LLM response during this iteration.

error()

@property
def error() -> Optional[str]

The error message from any exception that raised and interrupted this iteration.

exception()

@property
def exception() -> Optional[Exception]

The exception that interrupted this iteration.

failed_validations()

@property
def failed_validations() -> List[ValidatorLogs]

The validator logs for any validations that failed during this iteration.

status()

@property
def status() -> str

Representation of the end state of this iteration.

OneOf: pass, fail, error, not run

classes.history.outputs

Outputs Objects

failed_validations()

@property
def failed_validations() -> List[ValidatorLogs]

Returns the validator logs for any validation that failed.

status()

@property
def status() -> str

Representation of the end state of the validation run.

OneOf: pass, fail, error, not run

classes.history.call

Call Objects

prompt()

@property
def prompt() -> Optional[str]

The prompt as provided by the user when intializing or calling the Guard.

prompt_params()

@property
def prompt_params() -> Optional[Dict]

The prompt parameters as provided by the user when intializing or calling the Guard.

compiled_prompt()

@property
def compiled_prompt() -> Optional[str]

The initial compiled prompt that was passed to the LLM on the first call.

reask_prompts()

@property
def reask_prompts() -> Stack[Optional[str]]

The compiled prompts used during reasks.

Does not include the initial prompt.

instructions()

@property
def instructions() -> Optional[str]

The instructions as provided by the user when intializing or calling the Guard.

compiled_instructions()

@property
def compiled_instructions() -> Optional[str]

The initial compiled instructions that were passed to the LLM on the first call.

reask_instructions()

@property
def reask_instructions() -> Stack[str]

The compiled instructions used during reasks.

Does not include the initial instructions.

logs()

@property
def logs() -> Stack[str]

Returns all logs from all iterations as a stack.

tokens_consumed()

@property
def tokens_consumed() -> Optional[int]

Returns the total number of tokens consumed during all iterations with this call.

prompt_tokens_consumed()

@property
def prompt_tokens_consumed() -> Optional[int]

Returns the total number of prompt tokens consumed during all iterations with this call.

completion_tokens_consumed()

@property
def completion_tokens_consumed() -> Optional[int]

Returns the total number of completion tokens consumed during all iterations with this call.

raw_outputs()

@property
def raw_outputs() -> Stack[str]

The exact outputs from all LLM calls.

parsed_outputs()

@property
def parsed_outputs() -> Stack[Union[str, Dict]]

The outputs from the LLM after undergoing parsing but before validation.

validation_response()

@property
def validation_response() -> Optional[Union[str, Dict, ReAsk]]

The aggregated responses from the validation process across all iterations within the current call.

This value could contain ReAsks.

fixed_output()

@property
def fixed_output() -> Optional[Union[str, Dict]]

The cumulative output from the validation process across all current iterations with any automatic fixes applied.

Could still contain ReAsks if a fix was not available.

guarded_output()

@property
def guarded_output() -> Optional[Union[str, Dict]]

The complete validated output after all stages of validation are completed.

This property contains the aggregate validated output after all validation stages have been completed. Some values in the validated output may be "fixed" values that were corrected during validation.

This will only have a value if the Guard is in a passing state.

validated_output()

@property
@deprecated("""'Call.validated_output' is deprecated and will be removed in \
versions 0.5.0 and beyond. Use 'guarded_output' instead.""")
def validated_output() -> Optional[Union[str, Dict]]

The output from the LLM after undergoing validation.

This will only have a value if the Guard is in a passing state.

reasks()

@property
def reasks() -> Stack[ReAsk]

Reasks generated during validation that could not be automatically fixed.

These would be incorporated into the prompt for the next LLM call if additional reasks were granted.

validator_logs()

@property
def validator_logs() -> Stack[ValidatorLogs]

The results of each individual validation performed on the LLM responses during all iterations.

error()

@property
def error() -> Optional[str]

The error message from any exception that raised and interrupted the run.

exception()

@property
def exception() -> Optional[Exception]

The exception that interrupted the run.

failed_validations()

@property
def failed_validations() -> Stack[ValidatorLogs]

The validator logs for any validations that failed during the entirety of the run.

status()

@property
def status() -> str

Returns the cumulative status of the run based on the validity of the final merged output.

tree()

@property
def tree() -> Tree

Returns the tree.