Class: RubyLLM::Contract::Prompt::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_llm/contract/prompt/node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, content:) ⇒ Node

Returns a new instance of Node.



9
10
11
12
13
# File 'lib/ruby_llm/contract/prompt/node.rb', line 9

def initialize(type:, content:)
  @type = type
  @content = content.frozen? ? content : content.dup.freeze
  freeze
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



7
8
9
# File 'lib/ruby_llm/contract/prompt/node.rb', line 7

def content
  @content
end

#typeObject (readonly)

Returns the value of attribute type.



7
8
9
# File 'lib/ruby_llm/contract/prompt/node.rb', line 7

def type
  @type
end

Instance Method Details

#==(other) ⇒ Object



15
16
17
# File 'lib/ruby_llm/contract/prompt/node.rb', line 15

def ==(other)
  other.is_a?(self.class) && type == other.type && content == other.content
end

#to_hObject



19
20
21
# File 'lib/ruby_llm/contract/prompt/node.rb', line 19

def to_h
  { type: @type, content: @content }
end