Class: Ace::LLM::Molecules::InteractiveCommandBuilder
- Inherits:
-
Object
- Object
- Ace::LLM::Molecules::InteractiveCommandBuilder
- Defined in:
- lib/ace/llm/molecules/interactive_command_builder.rb
Instance Method Summary collapse
- #build(provider_model:, prompt:, model: nil, preset: nil, system: nil, cli_args: nil, system_append: nil, sandbox: nil, working_dir: nil, subprocess_env: nil) ⇒ Object
-
#initialize(registry: ClientRegistry.new) ⇒ InteractiveCommandBuilder
constructor
A new instance of InteractiveCommandBuilder.
Constructor Details
#initialize(registry: ClientRegistry.new) ⇒ InteractiveCommandBuilder
Returns a new instance of InteractiveCommandBuilder.
7 8 9 10 |
# File 'lib/ace/llm/molecules/interactive_command_builder.rb', line 7 def initialize(registry: ClientRegistry.new) @registry = registry @parser = ProviderModelParser.new(registry: registry) end |
Instance Method Details
#build(provider_model:, prompt:, model: nil, preset: nil, system: nil, cli_args: nil, system_append: nil, sandbox: nil, working_dir: nil, subprocess_env: nil) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/ace/llm/molecules/interactive_command_builder.rb', line 12 def build(provider_model:, prompt:, model: nil, preset: nil, system: nil, cli_args: nil, system_append: nil, sandbox: nil, working_dir: nil, subprocess_env: nil) parse_result = @parser.parse(provider_model) raise Error, parse_result.error unless parse_result.valid? resolved_preset = QueryInterface.send(:resolve_preset_name, parse_result.preset, preset) final_model = model || parse_result.model if final_model.nil? || final_model.empty? raise Error, "No model specified and no default available for #{parse_result.provider}" end final_prompt = prompt.to_s raise Error, "No prompt specified. Use positional prompt or --prompt." if final_prompt.empty? generation_opts = QueryInterface.send( :build_generation_opts, provider: parse_result.provider, preset: resolved_preset, thinking_level: parse_result.thinking_level, temperature: nil, max_tokens: nil, system_file: nil, prompt_file: nil, cli_args: cli_args, system_append: system_append, sandbox: sandbox, working_dir: working_dir, subprocess_env: subprocess_env, subprocess_command_prefix: nil, last_message_file: nil ) client = @registry.get_client(parse_result.provider, model: final_model) unless client.respond_to?(:interactive_supported?) && client.interactive_supported? raise Error, "Provider '#{parse_result.provider}' does not support interactive mode" end = [] << {role: "system", content: system} if system && !system.empty? << {role: "user", content: final_prompt} invocation = client.build_interactive_invocation(, **generation_opts) invocation.merge( provider: parse_result.provider, model: final_model, preset: resolved_preset, thinking_level: parse_result.thinking_level ) end |