Module: Legion::Extensions::Agentic::Language::Narrator::Helpers::LlmEnhancer

Defined in:
lib/legion/extensions/agentic/language/narrator/helpers/llm_enhancer.rb

Constant Summary collapse

SYSTEM_PROMPT =
<<~PROMPT
  You are the internal narrator for an autonomous AI agent built on LegionIO.
  You translate raw cognitive metrics into a flowing first-person internal monologue.
  Write 3-5 sentences that feel like genuine introspection, not a report.
  Vary your sentence structure. Use present tense. Be concise and vivid.
PROMPT
FAILURE_LOG_INTERVAL =
60
FAILURE_LOGGED_AT =
Concurrent::AtomicReference.new

Class Method Summary collapse

Class Method Details

.available?Boolean

Returns:

  • (Boolean)


28
29
30
31
32
33
# File 'lib/legion/extensions/agentic/language/narrator/helpers/llm_enhancer.rb', line 28

def available?
  !!(defined?(Legion::LLM) && Legion::LLM.respond_to?(:started?) && Legion::LLM.started?)
rescue StandardError => e
  log.debug("[narrator:llm] available? check failed: #{e.class}: #{e.message}")
  false
end

.narrate(sections_data:) ⇒ Object



35
36
37
38
39
40
41
42
# File 'lib/legion/extensions/agentic/language/narrator/helpers/llm_enhancer.rb', line 35

def narrate(sections_data:)
  prompt = build_narrate_prompt(sections_data)
  response = llm_ask(prompt)
  parse_narrate_response(response)
rescue StandardError => e
  log_failure(e)
  nil
end