Class: ActiveAgent::Providers::Anthropic::RequestType
- Inherits:
-
ActiveModel::Type::Value
- Object
- ActiveModel::Type::Value
- ActiveAgent::Providers::Anthropic::RequestType
- Defined in:
- lib/active_agent/providers/anthropic/_types.rb
Overview
ActiveModel type for casting and serializing Anthropic Request objects.
Handles conversion between Hash, Request, and serialized formats for API calls. The Request class now delegates to the official Anthropic gem model, eliminating the need for maintaining nested type definitions.
Instance Method Summary collapse
-
#cast(value) ⇒ Request?
Casts input to Request object.
- #deserialize(value) ⇒ Request?
-
#serialize(value) ⇒ Hash?
Serializes Request to Hash for API submission.
Instance Method Details
#cast(value) ⇒ Request?
Casts input to Request object.
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/active_agent/providers/anthropic/_types.rb', line 20 def cast(value) case value when Request value when Hash Request.new(**value.deep_symbolize_keys) when nil nil else raise ArgumentError, "Cannot cast #{value.class} to Request" end end |
#deserialize(value) ⇒ Request?
57 58 59 |
# File 'lib/active_agent/providers/anthropic/_types.rb', line 57 def deserialize(value) cast(value) end |
#serialize(value) ⇒ Hash?
Serializes Request to Hash for API submission.
Removes ‘:response_format` key as it’s a simulated feature not directly supported by Anthropic’s API.
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/active_agent/providers/anthropic/_types.rb', line 41 def serialize(value) case value when Request # Response Format is a simulated feature, not directly supported by API value.serialize.except(:response_format) when Hash value when nil nil else raise ArgumentError, "Cannot serialize #{value.class}" end end |