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

Copy Markdown View Source

Execution mode that loops while the chain needs a response.

After each LLM call, if the response contains tool calls, this mode:

  1. Executes the pending tool calls
  2. Calls the LLM again with the tool results
  3. Repeats until needs_response is false (no more tool calls)

The LLM always gets the last word after tool execution.

Usage

LLMChain.run(chain, mode: :while_needs_response)
# or
LLMChain.run(chain, mode: LangChain.Chains.LLMChain.Modes.WhileNeedsResponse)