Class: ActiveAgent::Providers::OpenRouter::Requests::PredictionType

Inherits:
ActiveModel::Type::Value
  • Object
show all
Defined in:
lib/active_agent/providers/open_router/requests/_types.rb

Overview

Type for Prediction

Instance Method Summary collapse

Instance Method Details

#cast(value) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/active_agent/providers/open_router/requests/_types.rb', line 51

def cast(value)
  case value
  when Prediction
    value
  when Hash
    Prediction.new(**value.deep_symbolize_keys)
  when nil
    nil
  else
    raise ArgumentError, "Cannot cast #{value.class} to Prediction"
  end
end

#deserialize(value) ⇒ Object



77
78
79
# File 'lib/active_agent/providers/open_router/requests/_types.rb', line 77

def deserialize(value)
  cast(value)
end

#serialize(value) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/active_agent/providers/open_router/requests/_types.rb', line 64

def serialize(value)
  case value
  when Prediction
    value.serialize
  when Hash
    value
  when nil
    nil
  else
    raise ArgumentError, "Cannot serialize #{value.class}"
  end
end