Module: Leva::ApplicationHelper

Included in:
ExperimentsController, WorkbenchController
Defined in:
app/helpers/leva/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#load_evaluatorsArray<Class>

Loads all evaluator classes that inherit from Leva::BaseEval

Returns:

  • (Array<Class>)

    An array of evaluator classes



6
7
8
# File 'app/helpers/leva/application_helper.rb', line 6

def load_evaluators
  load_classes_from_directory('app/evals', Leva::BaseEval) || []
end

#load_predefined_promptsArray<Array<String, String>>

Loads predefined prompts from markdown files

Returns:

  • (Array<Array<String, String>>)

    An array of prompt name and content pairs



20
21
22
23
24
25
26
27
# File 'app/helpers/leva/application_helper.rb', line 20

def load_predefined_prompts
  prompts = Dir.glob(Rails.root.join('app', 'prompts', '*.md')).map do |file|
    name = File.basename(file, '.md').titleize
    content = File.read(file)
    [name, content]
  end
  prompts
end

#load_runnersArray<Class>

Loads all runner classes that inherit from Leva::BaseRun

Returns:

  • (Array<Class>)

    An array of runner classes



13
14
15
# File 'app/helpers/leva/application_helper.rb', line 13

def load_runners
  load_classes_from_directory('app/runners', Leva::BaseRun) || []
end