Class: Inquirex::LLM::NullAdapter

Inherits:
Adapter
  • Object
show all
Defined in:
lib/inquirex/llm/null_adapter.rb

Overview

Test adapter that returns schema-conformant placeholder values without calling any LLM API. Useful for testing flows that include LLM steps.

For extract steps with a schema, returns a hash of default values matching each field's declared type. Fields constrained to a list of allowed values (enum/multi_enum resolved from questions) return the first allowed value, so placeholders stay valid answers for the downstream question. Without a schema, returns a placeholder string.

Examples:

adapter = Inquirex::LLM::NullAdapter.new
result = adapter.call(extract_node, answers)
# => { industry: "", employee_count: 0, entity_type: "llc", ... }

Constant Summary collapse

TYPE_DEFAULTS =
{
  string:     "",
  text:       "",
  integer:    0,
  decimal:    0.0,
  currency:   0.0,
  boolean:    false,
  enum:       "",
  multi_enum: [],
  date:       "",
  email:      "",
  phone:      "",
  array:      [],
  hash:       {}
}.freeze

Instance Method Summary collapse

Methods inherited from Adapter

#normalize_output, #source_answers, #summary_input, #validate_output!

Instance Method Details

#call(node, _answers = {}) ⇒ Hash, String

Returns placeholder output matching the node's schema or verb.

Parameters:

  • node (LLM::Node)
  • _answers (Hash) (defaults to: {})

    ignored

Returns:

  • (Hash, String)


40
41
42
43
44
45
46
47
48
# File 'lib/inquirex/llm/null_adapter.rb', line 40

def call(node, _answers = {})
  if node.schema
    node.schema.fields.each_with_object({}) do |(name, type), acc|
      acc[name] = placeholder_for(node.schema, name, type)
    end
  else
    "(placeholder #{node.verb} output for #{node.id})"
  end
end

#summarize(node, transcript, _answers = {}) ⇒ String

Placeholder summary, in the markdown shape a real summary takes — so a renderer wired against this adapter exercises its heading, list, and paragraph handling rather than one unbroken line.

Parameters:

  • node (LLM::Node)

    the summarize step

  • transcript (String)

    the session transcript

  • _answers (Hash) (defaults to: {})

    ignored

Returns:

  • (String)

    markdown



58
59
60
61
62
63
64
65
66
67
# File 'lib/inquirex/llm/null_adapter.rb', line 58

def summarize(node, transcript, _answers = {})
  <<~MARKDOWN.strip
    This is a placeholder summary for #{node.id}. No language model was called.

    ## What the session contained

    - A transcript of #{transcript.to_s.strip.length} characters.
    - Nothing else worth reporting, because this adapter invents nothing.
  MARKDOWN
end