Exception: DSPy::PredictionInvalidError
- Inherits:
-
StandardError
- Object
- StandardError
- DSPy::PredictionInvalidError
- Extended by:
- T::Sig
- Defined in:
- lib/dspy/predict.rb
Overview
Exception raised when prediction fails validation
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
-
#initialize(errors, context: nil) ⇒ PredictionInvalidError
constructor
A new instance of PredictionInvalidError.
Constructor Details
#initialize(errors, context: nil) ⇒ PredictionInvalidError
Returns a new instance of PredictionInvalidError.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/dspy/predict.rb', line 16 def initialize(errors, context: nil) @errors = errors @context = context # Format the error message using ErrorFormatter for better readability = if errors.key?(:output) && errors[:output].is_a?(String) # This is likely a type validation error from Sorbet formatted = DSPy::ErrorFormatter.format_error(errors[:output], context) "Prediction validation failed:\n\n#{formatted}" elsif errors.key?(:input) && errors[:input].is_a?(String) # This is an input validation error formatted = DSPy::ErrorFormatter.format_error(errors[:input], context) "Input validation failed:\n\n#{formatted}" else # Fallback to original format for any other error structure "Prediction validation failed: #{errors}" end super() end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
41 42 43 |
# File 'lib/dspy/predict.rb', line 41 def context @context end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
38 39 40 |
# File 'lib/dspy/predict.rb', line 38 def errors @errors end |