orca_sdk.telemetry#
TelemetryMode
module-attribute
#
Mode for saving telemetry. One of:
"off"
: Do not save telemetry"on"
: Save telemetry asynchronously unless theORCA_SAVE_TELEMETRY_SYNCHRONOUSLY
environment variable is set."sync"
: Save telemetry synchronously"async"
: Save telemetry asynchronously
FeedbackCategory
#
A category of feedback for predictions.
Categories are created automatically, the first time feedback with a new name is recorded. The value type of the category is inferred from the first recorded value. Subsequent feedback for the same category must be of the same type. Categories are not model specific.
Attributes:
-
id
(str
) –Unique identifier for the category.
-
name
(str
) –Name of the category.
-
value_type
(type[bool] | type[float]
) –Type that values for this category must have.
-
created_at
(datetime
) –When the category was created.
all
classmethod
#
Get a list of all existing feedback categories.
Returns:
-
list[FeedbackCategory]
–List with information about all existing feedback categories.
drop
classmethod
#
Drop all feedback for this category and drop the category itself, allowing it to be recreated with a different value type.
Warning
This will delete all feedback in this category across all models.
Parameters:
-
name
(str
) –Name of the category to drop.
Raises:
-
LookupError
–If the category is not found.
PredictionBase
#
Bases: ABC
explain
#
Print an explanation of the prediction as a stream of text.
Parameters:
-
refresh
(bool
, default:False
) –Force the explanation agent to re-run even if an explanation already exists.
get
classmethod
#
Fetch a prediction or predictions
Parameters:
Returns:
Raises:
-
LookupError
–If no prediction with the given id is found
Examples:
Fetch a single prediction:
Fetch multiple predictions:
add_tag
#
remove_tag
#
record_feedback
#
Record feedback for the prediction.
We support recording feedback in several categories for each prediction. A
FeedbackCategory
is created automatically,
the first time feedback with a new name is recorded. Categories are global across models.
The value type of the category is inferred from the first recorded value. Subsequent
feedback for the same category must be of the same type.
Parameters:
-
category
(str
) –Name of the category under which to record the feedback.
-
value
(bool | float
) –Feedback value to record, should be
True
for positive feedback andFalse
for negative feedback or afloat
between-1.0
and+1.0
where negative values indicate negative feedback and positive values indicate positive feedback. -
comment
(str | None
, default:None
) –Optional comment to record with the feedback.
Examples:
Record whether a suggestion was accepted or rejected:
Record star rating as normalized continuous score between -1.0
and +1.0
:
Raises:
-
ValueError
–If the value does not match previous value types for the category, or is a
float
that is not between-1.0
and+1.0
.
delete_feedback
#
Delete prediction feedback for a specific category.
Parameters:
-
category
(str
) –Name of the category of the feedback to delete.
Raises:
-
ValueError
–If the category is not found.
inspect
#
Display an interactive UI with the details about this prediction
Note
This method is only available in Jupyter notebooks.
ClassificationPrediction
#
Bases: PredictionBase
Labeled prediction result from a ClassificationModel
Attributes:
-
prediction_id
–Unique identifier of this prediction used for feedback
-
label
(int
) –Label predicted by the model
-
label_name
(str
) –Human-readable name of the label
-
confidence
(str
) –Confidence of the prediction
-
anomaly_score
(str
) –Anomaly score of the input
-
input_value
(str
) –The input value used for the prediction
-
expected_label
(int | None
) –Expected label for the prediction, useful when evaluating the model
-
expected_label_name
(str | None
) –Human-readable name of the expected label
-
memory_lookups
(list[LabeledMemoryLookup]
) –Memories used by the model to make the prediction
-
explanation
(list[LabeledMemoryLookup]
) –Natural language explanation of the prediction, only available if the model has the Explain API enabled
-
tags
(list[LabeledMemoryLookup]
) –Tags for the prediction, useful for filtering and grouping predictions
-
model
(ClassificationModel
) –Model used to make the prediction
-
memoryset
(LabeledMemoryset
) –Memoryset that was used to lookup memories to ground the prediction
explain
#
Print an explanation of the prediction as a stream of text.
Parameters:
-
refresh
(bool
, default:False
) –Force the explanation agent to re-run even if an explanation already exists.
get
classmethod
#
Fetch a prediction or predictions
Parameters:
Returns:
Raises:
-
LookupError
–If no prediction with the given id is found
Examples:
Fetch a single prediction:
Fetch multiple predictions:
add_tag
#
remove_tag
#
record_feedback
#
Record feedback for the prediction.
We support recording feedback in several categories for each prediction. A
FeedbackCategory
is created automatically,
the first time feedback with a new name is recorded. Categories are global across models.
The value type of the category is inferred from the first recorded value. Subsequent
feedback for the same category must be of the same type.
Parameters:
-
category
(str
) –Name of the category under which to record the feedback.
-
value
(bool | float
) –Feedback value to record, should be
True
for positive feedback andFalse
for negative feedback or afloat
between-1.0
and+1.0
where negative values indicate negative feedback and positive values indicate positive feedback. -
comment
(str | None
, default:None
) –Optional comment to record with the feedback.
Examples:
Record whether a suggestion was accepted or rejected:
Record star rating as normalized continuous score between -1.0
and +1.0
:
Raises:
-
ValueError
–If the value does not match previous value types for the category, or is a
float
that is not between-1.0
and+1.0
.
delete_feedback
#
Delete prediction feedback for a specific category.
Parameters:
-
category
(str
) –Name of the category of the feedback to delete.
Raises:
-
ValueError
–If the category is not found.
inspect
#
Display an interactive UI with the details about this prediction
Note
This method is only available in Jupyter notebooks.
update
#
Update the prediction.
Note
If a field is not provided, it will default to UNSET and not be updated.
Parameters:
recommend_action
#
Get an action recommendation for improving this prediction.
Analyzes the prediction and suggests the most effective action to improve model performance, such as adding memories, detecting mislabels, removing duplicates, or finetuning.
Parameters:
-
refresh
(bool
, default:False
) –Force the action recommendation agent to re-run even if a recommendation already exists
Returns:
-
str
–Tuple of (action, rationale) where:
-
str
–- action: The recommended action (“add_memories”, “detect_mislabels”, “remove_duplicates”, or “finetuning”) that would resolve the mislabeling
-
tuple[str, str]
–- rationale: Explanation for why this action was recommended
Raises:
-
ValueError
–If the prediction has no prediction ID
-
RuntimeError
–If the lighthouse API key is not configured
Examples:
Get action recommendation for an incorrect prediction:
generate_memory_suggestions
#
Generate synthetic memory suggestions to improve this prediction.
Creates new example memories that are similar to the input but have clearer signals for the expected label. These can be added to the memoryset to improve model performance on similar inputs.
Parameters:
-
num_memories
(int
, default:3
) –Number of memory suggestions to generate (default: 3)
Returns:
-
AddMemorySuggestions
–List of dictionaries that can be directly passed to memoryset.insert().
-
AddMemorySuggestions
–Each dictionary contains:
-
AddMemorySuggestions
–- “value”: The suggested memory text
-
AddMemorySuggestions
–- “label”: The suggested label as an integer
Raises:
-
ValueError
–If the prediction has no prediction ID
-
RuntimeError
–If the lighthouse API key is not configured
Examples:
Generate memory suggestions for an incorrect prediction:
RegressionPrediction
#
Bases: PredictionBase
Score-based prediction result from a RegressionModel
Attributes:
-
prediction_id
–Unique identifier of this prediction used for feedback
-
score
(float
) –Score predicted by the model
-
confidence
(float
) –Confidence of the prediction
-
anomaly_score
(float
) –Anomaly score of the input
-
input_value
(float
) –The input value used for the prediction
-
expected_score
(float | None
) –Expected score for the prediction, useful when evaluating the model
-
memory_lookups
(list[ScoredMemoryLookup]
) –Memories used by the model to make the prediction
-
explanation
(str
) –Natural language explanation of the prediction, only available if the model has the Explain API enabled
-
tags
(str
) –Tags for the prediction, useful for filtering and grouping predictions
-
model
(RegressionModel
) –Model used to make the prediction
-
memoryset
(ScoredMemoryset
) –Memoryset that was used to lookup memories to ground the prediction
explanation
property
#
The explanation for this prediction. Requires lighthouse_client_api_key
to be set.
explain
#
Print an explanation of the prediction as a stream of text.
Parameters:
-
refresh
(bool
, default:False
) –Force the explanation agent to re-run even if an explanation already exists.
get
classmethod
#
Fetch a prediction or predictions
Parameters:
Returns:
Raises:
-
LookupError
–If no prediction with the given id is found
Examples:
Fetch a single prediction:
Fetch multiple predictions:
add_tag
#
remove_tag
#
record_feedback
#
Record feedback for the prediction.
We support recording feedback in several categories for each prediction. A
FeedbackCategory
is created automatically,
the first time feedback with a new name is recorded. Categories are global across models.
The value type of the category is inferred from the first recorded value. Subsequent
feedback for the same category must be of the same type.
Parameters:
-
category
(str
) –Name of the category under which to record the feedback.
-
value
(bool | float
) –Feedback value to record, should be
True
for positive feedback andFalse
for negative feedback or afloat
between-1.0
and+1.0
where negative values indicate negative feedback and positive values indicate positive feedback. -
comment
(str | None
, default:None
) –Optional comment to record with the feedback.
Examples:
Record whether a suggestion was accepted or rejected:
Record star rating as normalized continuous score between -1.0
and +1.0
:
Raises:
-
ValueError
–If the value does not match previous value types for the category, or is a
float
that is not between-1.0
and+1.0
.
delete_feedback
#
Delete prediction feedback for a specific category.
Parameters:
-
category
(str
) –Name of the category of the feedback to delete.
Raises:
-
ValueError
–If the category is not found.
inspect
#
Display an interactive UI with the details about this prediction
Note
This method is only available in Jupyter notebooks.