Class: CompletionKit::PromptfooImporter
- Inherits:
-
Object
- Object
- CompletionKit::PromptfooImporter
- Defined in:
- app/services/completion_kit/promptfoo_importer.rb
Defined Under Namespace
Classes: Result
Constant Summary collapse
- JUDGE_ASSERTS =
%w[llm-rubric g-eval model-graded-closedqa factuality].freeze
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(content) ⇒ PromptfooImporter
constructor
A new instance of PromptfooImporter.
Constructor Details
#initialize(content) ⇒ PromptfooImporter
Returns a new instance of PromptfooImporter.
14 15 16 |
# File 'app/services/completion_kit/promptfoo_importer.rb', line 14 def initialize(content) @content = content.to_s end |
Class Method Details
.call(content) ⇒ Object
10 11 12 |
# File 'app/services/completion_kit/promptfoo_importer.rb', line 10 def self.call(content) new(content).call end |
Instance Method Details
#call ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/services/completion_kit/promptfoo_importer.rb', line 18 def call config = parse return failure("Could not parse YAML: #{@parse_error}") if config.nil? return failure("Top-level YAML must be a mapping of promptfoo config keys.") unless config.is_a?(Hash) ApplicationRecord.transaction do providers = import_providers(config) prompts = import_prompts(config, default_model(config)) dataset = import_dataset(config) metrics = import_metrics(config) Result.new(ok: true, error: nil, prompts: prompts, dataset: dataset, metrics: metrics, providers: providers) end end |