Module: Inquirex::LLM::DSL::FlowBuilderExtension

Defined in:
lib/inquirex/llm/dsl/flow_builder.rb

Overview

Mixin that adds LLM verb methods to Inquirex::DSL::FlowBuilder. Prepended automatically when require "inquirex-llm" is called, so that Inquirex.define gains extract (and its clarify alias) without needing a separate entry point.

All core verbs (ask, say, header, btw, warning, confirm) remain unchanged — LLM verbs are purely additive. The mixin must be prepended (not included) because it overrides #build: LLM steps are built lazily at #build time, once every step in the flow is known, so that schema question references can resolve forward to questions defined after the LLM step.

Constant Summary collapse

TRANSCRIPT_ACCUMULATOR =

Accumulator added when a flow declares summarize without declaring anywhere for the narrative to accumulate.

:transcript

Instance Method Summary collapse

Instance Method Details

#buildObject

Builds any deferred LLM steps (now that the full node map exists), then produces the frozen Definition via the core builder.



73
74
75
76
77
78
# File 'lib/inquirex/llm/dsl/flow_builder.rb', line 73

def build
  validate_summarize_placement!
  ensure_transcript_accumulator!
  resolve_llm_steps!
  super
end

#extract(id) ⇒ Object Also known as: clarify

Defines an LLM extraction step: takes free-text input and produces structured data matching the declared schema.

Parameters:

  • id (Symbol)

    step id



26
27
28
# File 'lib/inquirex/llm/dsl/flow_builder.rb', line 26

def extract(id, &)
  add_llm_step(id, :extract, &)
end

#summarize(id) ⇒ Object

Closes the flow with a prose summary of the whole session.

Takes no prompt (the gem owns it — see Prompts::SUMMARIZE), no schema, and no from: its input is always the session transcript, and its output is markdown for the user to read, keep, and print. It must be the last step declared in the flow, and a flow may declare only one.

Declaring it also guarantees the flow has somewhere to summarise from: if no :text accumulator was declared, a :transcript one is added automatically.

Examples:

summarize :wrap_up do
  temperature 0.4
end

Parameters:

  • id (Symbol)

    step id



58
59
60
# File 'lib/inquirex/llm/dsl/flow_builder.rb', line 58

def summarize(id, &)
  add_llm_step(id, :summarize, &)
end