Class: LangGraphRB::LLMNode

Inherits:
Node
  • Object
show all
Defined in:
lib/langgraph_rb/node.rb

Overview

Specialized node for LLM calls

Instance Attribute Summary collapse

Attributes inherited from Node

#block, #name

Instance Method Summary collapse

Methods inherited from Node

#inspect, #to_s

Constructor Details

#initialize(name, llm_client:, system_prompt: nil, &block) ⇒ LLMNode

Returns a new instance of LLMNode.



40
41
42
43
44
45
# File 'lib/langgraph_rb/node.rb', line 40

def initialize(name, llm_client:, system_prompt: nil, &block)
  @llm_client = llm_client
  @system_prompt = system_prompt
  
  super(name, &block)
end

Instance Attribute Details

#llm_clientObject (readonly)

Returns the value of attribute llm_client.



38
39
40
# File 'lib/langgraph_rb/node.rb', line 38

def llm_client
  @llm_client
end

#system_promptObject (readonly)

Returns the value of attribute system_prompt.



38
39
40
# File 'lib/langgraph_rb/node.rb', line 38

def system_prompt
  @system_prompt
end

Instance Method Details

#call(state, context: nil) ⇒ Object



47
48
49
50
51
52
53
54
# File 'lib/langgraph_rb/node.rb', line 47

def call(state, context: nil)
  # If no custom block provided, use default LLM behavior
  if @callable.nil? || @callable == method(:default_llm_call)
    default_llm_call(state, context)
  else
    super(state, context: context)
  end
end