Class: Ace::Review::Molecules::LlmExecutor
- Inherits:
-
Object
- Object
- Ace::Review::Molecules::LlmExecutor
- Defined in:
- lib/ace/review/molecules/llm_executor.rb
Overview
Executes LLM queries for code reviews using Ruby API
Constant Summary collapse
- PROMPT_SIZE_WARNING_RATIO =
Warning ratio: warn when estimated tokens exceed 80% of model context limit
0.8
Instance Method Summary collapse
-
#execute(system_prompt:, user_prompt:, session_dir:, model: nil, output_file: nil, timeout: nil) ⇒ Hash
Execute an LLM query using Ruby API.
-
#initialize ⇒ LlmExecutor
constructor
A new instance of LlmExecutor.
Constructor Details
#initialize ⇒ LlmExecutor
Returns a new instance of LlmExecutor.
13 14 15 |
# File 'lib/ace/review/molecules/llm_executor.rb', line 13 def initialize @default_model = Ace::Review.get("defaults", "model") || "google:gemini-2.5-flash" end |
Instance Method Details
#execute(system_prompt:, user_prompt:, session_dir:, model: nil, output_file: nil, timeout: nil) ⇒ Hash
Execute an LLM query using Ruby API
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 |
# File 'lib/ace/review/molecules/llm_executor.rb', line 24 def execute(system_prompt:, user_prompt:, session_dir:, model: nil, output_file: nil, timeout: nil) model ||= @default_model # Warn if prompt is large warn_if_prompt_large(system_prompt, user_prompt, model) # Check if ace-llm Ruby API is available unless ruby_api_available? return { success: false, response: nil, error: "ace-llm Ruby API not available. Please install ace-llm gem or use --dry-run" } end # Use Ruby API directly for v0.13.0 architecture execute_with_ruby_api( system_prompt, user_prompt, model, session_dir, output_file, timeout ) rescue => e { success: false, response: nil, error: "LLM execution failed: #{e.}" } end |