Class: RubyLLM::Contract::Prompt::Nodes::ExampleNode

Inherits:
RubyLLM::Contract::Prompt::Node show all
Defined in:
lib/ruby_llm/contract/prompt/nodes/example_node.rb

Instance Attribute Summary collapse

Attributes inherited from RubyLLM::Contract::Prompt::Node

#content, #type

Instance Method Summary collapse

Constructor Details

#initialize(input:, output:) ⇒ ExampleNode

Returns a new instance of ExampleNode.



10
11
12
13
14
# File 'lib/ruby_llm/contract/prompt/nodes/example_node.rb', line 10

def initialize(input:, output:)
  @input = input.frozen? ? input : input.dup.freeze
  @output = output.frozen? ? output : output.dup.freeze
  super(type: :example, content: nil)
end

Instance Attribute Details

#inputObject (readonly)

Returns the value of attribute input.



8
9
10
# File 'lib/ruby_llm/contract/prompt/nodes/example_node.rb', line 8

def input
  @input
end

#outputObject (readonly)

Returns the value of attribute output.



8
9
10
# File 'lib/ruby_llm/contract/prompt/nodes/example_node.rb', line 8

def output
  @output
end

Instance Method Details

#==(other) ⇒ Object



16
17
18
# File 'lib/ruby_llm/contract/prompt/nodes/example_node.rb', line 16

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

#to_hObject



20
21
22
# File 'lib/ruby_llm/contract/prompt/nodes/example_node.rb', line 20

def to_h
  { type: :example, input: @input, output: @output }
end