Module: Legion::Extensions::MoralReasoning::Helpers::LlmEnhancer
- Defined in:
- lib/legion/extensions/moral_reasoning/helpers/llm_enhancer.rb
Constant Summary collapse
- SYSTEM_PROMPT =
"You are the moral reasoning engine for an autonomous AI agent built on LegionIO.\nYou apply ethical frameworks to evaluate actions and resolve dilemmas.\nBe rigorous, analytical, and fair. Consider multiple perspectives.\nOutput structured reasoning, not opinions. Be concise.\n"
Class Method Summary collapse
- .available? ⇒ Boolean
- .evaluate_action(action:, description:, foundations:) ⇒ Object
- .resolve_dilemma(dilemma_description:, options:, framework:) ⇒ Object
Class Method Details
.available? ⇒ Boolean
17 18 19 20 21 |
# File 'lib/legion/extensions/moral_reasoning/helpers/llm_enhancer.rb', line 17 def available? !!(defined?(Legion::LLM) && Legion::LLM.respond_to?(:started?) && Legion::LLM.started?) rescue StandardError false end |
.evaluate_action(action:, description:, foundations:) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/legion/extensions/moral_reasoning/helpers/llm_enhancer.rb', line 23 def evaluate_action(action:, description:, foundations:) response = llm_ask(build_evaluate_action_prompt(action: action, description: description, foundations: foundations)) parse_evaluate_action_response(response) rescue StandardError => e Legion::Logging.warn "[moral_reasoning:llm] evaluate_action failed: #{e.message}" nil end |
.resolve_dilemma(dilemma_description:, options:, framework:) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/legion/extensions/moral_reasoning/helpers/llm_enhancer.rb', line 32 def resolve_dilemma(dilemma_description:, options:, framework:) response = llm_ask(build_resolve_dilemma_prompt(dilemma_description: dilemma_description, options: , framework: framework)) parse_resolve_dilemma_response(response) rescue StandardError => e Legion::Logging.warn "[moral_reasoning:llm] resolve_dilemma failed: #{e.message}" nil end |