Class: LittleGhost::Content::Reasoning
- Inherits:
-
Data
- Object
- Data
- LittleGhost::Content::Reasoning
- Includes:
- Module.new do # :nodoc: def to_h = Content.serialize(self) def to_json(*arguments) = JSON.generate(to_h, *arguments) end
- Defined in:
- lib/little_ghost/content.rb,
lib/little_ghost/content.rb
Overview
Preserves provider reasoning without forcing every provider into one representation. A value may carry visible text, a provider signature, opaque redacted bytes, or provider-specific detail objects.
Redacted bytes are mutually exclusive with text and signatures so they can round-trip without exposing or changing provider-managed content.
Instance Attribute Summary collapse
-
#details ⇒ Object
readonly
Returns the value of attribute details.
-
#redacted_content ⇒ Object
readonly
Returns the value of attribute redacted_content.
-
#signature ⇒ Object
readonly
Returns the value of attribute signature.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(text: "", signature: nil, redacted_content: nil, details: nil) ⇒ Reasoning
constructor
A new instance of Reasoning.
Constructor Details
#initialize(text: "", signature: nil, redacted_content: nil, details: nil) ⇒ Reasoning
Returns a new instance of Reasoning.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/little_ghost/content.rb', line 68 def initialize(text: "", signature: nil, redacted_content: nil, details: nil) text = String(text) signature = String(signature) if signature redacted_content = String(redacted_content).b if redacted_content if details unless details.is_a?(Array) && details.all? { |detail| detail.is_a?(Hash) } raise ArgumentError, "reasoning details must be an array of objects" end end if redacted_content && (!text.empty? || !signature.to_s.empty?) raise ArgumentError, "reasoning content cannot contain both text and redacted content" end super( text: text.freeze, signature: signature&.freeze, redacted_content: redacted_content&.freeze, details: ) rescue TypeError raise ArgumentError, "reasoning content is invalid" end |
Instance Attribute Details
#details ⇒ Object (readonly)
Returns the value of attribute details
65 66 67 |
# File 'lib/little_ghost/content.rb', line 65 def details @details end |
#redacted_content ⇒ Object (readonly)
Returns the value of attribute redacted_content
65 66 67 |
# File 'lib/little_ghost/content.rb', line 65 def redacted_content @redacted_content end |
#signature ⇒ Object (readonly)
Returns the value of attribute signature
65 66 67 |
# File 'lib/little_ghost/content.rb', line 65 def signature @signature end |
#text ⇒ Object (readonly)
Returns the value of attribute text
65 66 67 |
# File 'lib/little_ghost/content.rb', line 65 def text @text end |