Class: Braintrust::Server::Services::List
- Inherits:
-
Object
- Object
- Braintrust::Server::Services::List
- Defined in:
- lib/braintrust/server/services/list_service.rb
Overview
Framework-agnostic service for listing evaluators. Returns a plain Hash (not a Rack triplet) suitable for JSON.dump.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(evaluators) ⇒ List
constructor
A new instance of List.
Constructor Details
#initialize(evaluators) ⇒ List
Returns a new instance of List.
11 12 13 |
# File 'lib/braintrust/server/services/list_service.rb', line 11 def initialize(evaluators) @evaluators = evaluators end |
Instance Method Details
#call ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/braintrust/server/services/list_service.rb', line 15 def call result = {} current_evaluators.each do |name, evaluator| scores = (evaluator.scorers || []).each_with_index.map do |scorer, i| scorer_name = scorer.respond_to?(:name) ? scorer.name : "score_#{i}" {"name" => scorer_name} end entry = {"scores" => scores} params = serialize_parameters(evaluator.parameters) entry["parameters"] = params if params result[name] = entry end result end |