Class: Legion::MCP::Tools::EvalRun

Inherits:
MCP::Tool
  • Object
show all
Extended by:
Logging::Helper
Defined in:
lib/legion/mcp/tools/eval_run.rb

Class Method Summary collapse

Class Method Details

.call(evaluator_name:, input:, output:, expected: nil) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/legion/mcp/tools/eval_run.rb', line 23

def call(evaluator_name:, input:, output:, expected: nil)
  log.info('Starting legion.mcp.tools.eval_run.call')
  return error_response('lex-eval is not loaded') unless extension_loaded?('eval')

  require 'legion/extensions/eval/client'
  client = Legion::Extensions::Eval::Client.new(db: db)
  inputs = [{ input: input, output: output, expected: expected }.compact]
  result = client.run_evaluation(evaluator_name: evaluator_name, inputs: inputs)
  text_response(result)
rescue StandardError => e
  handle_exception(e, level: :warn, operation: 'legion.mcp.tools.eval_run.call')
  log.warn("EvalRun#call failed: #{e.message}")
  error_response("Failed to run evaluation: #{e.message}")
end