Class: Langfuse::ExperimentRunner Private
- Inherits:
-
Object
- Object
- Langfuse::ExperimentRunner
- Defined in:
- lib/langfuse/experiment_runner.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Orchestrates an experiment run: executes a task against each item, runs evaluators, persists scores, and links dataset run items.
This class is not intended to be instantiated directly. Use Client#run_experiment or DatasetClient#run_experiment instead.
rubocop:disable Metrics/ClassLength
Instance Method Summary collapse
- #execute ⇒ ExperimentResult private
-
#initialize(client:, name:, items:, task:, evaluators: [], run_evaluators: [], metadata: nil, description: nil, run_name: nil) ⇒ ExperimentRunner
constructor
private
rubocop:disable Metrics/ParameterLists.
Constructor Details
#initialize(client:, name:, items:, task:, evaluators: [], run_evaluators: [], metadata: nil, description: nil, run_name: nil) ⇒ ExperimentRunner
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
rubocop:disable Metrics/ParameterLists
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/langfuse/experiment_runner.rb', line 24 def initialize(client:, name:, items:, task:, evaluators: [], run_evaluators: [], metadata: nil, description: nil, run_name: nil) @client = client @name = name @items = items.map { |item| normalize_item(item) } @task = task @evaluators = evaluators @run_evaluators = run_evaluators @metadata = || {} @description = description @run_name = run_name || "#{name} - #{Time.now.utc.iso8601}" @logger = Langfuse.configuration.logger @dataset_run_id = nil @dataset_id = nil end |
Instance Method Details
#execute ⇒ ExperimentResult
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/langfuse/experiment_runner.rb', line 42 def execute item_results = @items.each_with_index.map { |item, index| process_item(item, index) } flush_all run_evals = execute_run_evaluators(item_results) flush_all if run_evals.any? ExperimentResult.new( name: @name, item_results: item_results, run_evaluations: run_evals, run_name: @run_name, description: @description, dataset_run_id: @dataset_run_id, dataset_run_url: build_dataset_run_url ) end |