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 clarify/detour steps with a schema, returns a hash of default values matching each field’s declared type. For describe/summarize steps, returns a placeholder string.

Examples:

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

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

#source_answers, #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)


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

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