Class: RosettAi::Adopter::ExecutorResolver

Inherits:
Object
  • Object
show all
Defined in:
lib/rosett_ai/adopter/executor_resolver.rb

Overview

Resolves the correct executor for an engine by reading its manifest to determine the API type and constructor kwargs.

SDK-based engines (api_gem) receive api_key: and base_url:. HTTP-based engines (api_type: http|openai_compatible) receive endpoint: and model: from the manifest defaults. CLI-based engines (api_type: cli) receive binary: from the manifest.

Instance Method Summary collapse

Constructor Details

#initialize(engine_name) ⇒ ExecutorResolver

Returns a new instance of ExecutorResolver.



16
17
18
19
# File 'lib/rosett_ai/adopter/executor_resolver.rb', line 16

def initialize(engine_name)
  @engine_name = engine_name.to_s
  @manifest = RosettAi::Engines::Registry.manifest(@engine_name)
end

Instance Method Details

#resolve(api_key: nil) ⇒ Object

Build an executor instance with the correct kwargs for the engine.

Parameters:

  • api_key (String, nil) (defaults to: nil)

    API key (SDK-based engines only)

Returns:

  • (Object)

    executor instance with #analyze method

Raises:



25
26
27
28
29
30
31
# File 'lib/rosett_ai/adopter/executor_resolver.rb', line 25

def resolve(api_key: nil)
  engine_mod = RosettAi::Engines::Registry.engine_module(@engine_name)
  executor_klass = engine_mod.executor_class
  raise RosettAi::AdoptError, "Engine '#{@engine_name}' does not provide an executor" unless executor_klass

  executor_klass.new(**build_kwargs(api_key))
end