LangChain.Chains.LLMChain.Modes.Step (LangChain v0.6.0)

Copy Markdown View Source

Execution mode that runs a single step at a time.

A "step" is: execute any pending tool calls, then call the LLM. If no tools were pending, just call the LLM.

Options

  • :should_continue? — Function (LLMChain.t() -> boolean()) called after each step. If it returns true, another step runs. If false or not provided, the mode returns after one step.

Usage

# Single step
LLMChain.run(chain, mode: :step)

# Auto-loop with condition
LLMChain.run(chain, mode: :step,
  should_continue?: fn chain ->
    chain.needs_response && length(chain.exchanged_messages) < 10
  end)