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

Class Method Summary collapse

Class Method Details

.available?Boolean

Returns:

  • (Boolean)


19
20
21
22
23
# File 'lib/legion/extensions/agentic/language/narrator/helpers/llm_enhancer.rb', line 19

def available?
  !!(defined?(Legion::LLM) && Legion::LLM.respond_to?(:started?) && Legion::LLM.started?)
rescue StandardError => _e
  false
end

.narrate(sections_data:) ⇒ Object



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

def narrate(sections_data:)
  prompt = build_narrate_prompt(sections_data)
  response = llm_ask(prompt)
  parse_narrate_response(response)
rescue StandardError => e
  Legion::Logging.warn("[narrator:llm] narrate failed: #{e.message}") # rubocop:disable Legion/HelperMigration/DirectLogging
  Legion::Logging.warn(e.backtrace) # rubocop:disable Legion/HelperMigration/DirectLogging
  nil
end