Class: Aidp::Providers::Gemini
- Includes:
- DebugMixin
- Defined in:
- lib/aidp/providers/gemini.rb
Constant Summary collapse
- MODEL_PATTERN =
Model name pattern for Gemini models
/^gemini-[\d.]+-(?:pro|flash|ultra)(?:-\d+)?$/i
Constants included from DebugMixin
DebugMixin::DEBUG_BASIC, DebugMixin::DEBUG_OFF, DebugMixin::DEBUG_VERBOSE
Constants inherited from Base
Base::ACTIVITY_STATES, Base::DEFAULT_STUCK_TIMEOUT, Base::TIMEOUT_ARCHITECTURE_ANALYSIS, Base::TIMEOUT_DEFAULT, Base::TIMEOUT_DOCUMENTATION_ANALYSIS, Base::TIMEOUT_FUNCTIONALITY_ANALYSIS, Base::TIMEOUT_IMPLEMENTATION, Base::TIMEOUT_QUICK_MODE, Base::TIMEOUT_REFACTORING_RECOMMENDATIONS, Base::TIMEOUT_REPOSITORY_ANALYSIS, Base::TIMEOUT_STATIC_ANALYSIS, Base::TIMEOUT_TEST_ANALYSIS
Constants included from MessageDisplay
Instance Attribute Summary
Attributes inherited from Base
#activity_state, #last_activity_time, #model, #start_time, #step_name, #stuck_timeout
Class Method Summary collapse
- .available? ⇒ Boolean
-
.discover_models ⇒ Array<Hash>
Discover available models from Gemini.
-
.firewall_requirements ⇒ Object
Get firewall requirements for Gemini provider.
-
.model_family(provider_model_name) ⇒ String
Normalize a provider-specific model name to its model family.
-
.provider_model_name(family_name) ⇒ String
Convert a model family name to the provider’s preferred model name.
-
.supports_model_family?(family_name) ⇒ Boolean
Check if this provider supports a given model family.
Instance Method Summary collapse
Methods included from DebugMixin
#debug_basic?, #debug_command, #debug_enabled?, #debug_error, #debug_execute_command, #debug_level, #debug_log, #debug_logger, #debug_provider, #debug_step, #debug_timing, #debug_verbose?, included, shared_logger
Methods inherited from Base
#activity_summary, #available?, #configure, discover_models_from_registry, #execution_time, #fetch_mcp_servers, #harness_config, #harness_health_status, #harness_healthy?, #harness_metrics, #harness_mode?, #initialize, #mark_completed, #mark_failed, #record_activity, #record_harness_request, #send_with_harness, #set_harness_context, #set_job_context, #setup_activity_monitoring, #stuck?, #supports_activity_monitoring?, #supports_mcp?, #time_since_last_activity, #update_activity_state
Methods included from Adapter
#available?, #capabilities, #classify_error, #dangerous_mode=, #dangerous_mode_enabled?, #dangerous_mode_flags, #error_metadata, #error_patterns, #fetch_mcp_servers, #health_status, #logging_metadata, #redact_secrets, #retryable_error?, #supports_dangerous_mode?, #supports_mcp?, #validate_config
Methods included from MessageDisplay
#display_message, included, #message_display_prompt
Constructor Details
This class inherits a constructor from Aidp::Providers::Base
Class Method Details
.available? ⇒ Boolean
14 15 16 |
# File 'lib/aidp/providers/gemini.rb', line 14 def self.available? !!Aidp::Util.which("gemini") end |
.discover_models ⇒ Array<Hash>
Discover available models from Gemini
Note: Gemini CLI doesn’t have a standard model listing command Returns registry-based models that match Gemini patterns
52 53 54 55 56 |
# File 'lib/aidp/providers/gemini.rb', line 52 def self.discover_models return [] unless available? discover_models_from_registry(MODEL_PATTERN, "gemini") end |
.firewall_requirements ⇒ Object
Get firewall requirements for Gemini provider
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/aidp/providers/gemini.rb', line 59 def self.firewall_requirements { domains: [ "generativelanguage.googleapis.com", "oauth2.googleapis.com", "accounts.google.com", "www.googleapis.com" ], ip_ranges: [] } end |
.model_family(provider_model_name) ⇒ String
Normalize a provider-specific model name to its model family
Gemini may use version suffixes (e.g., “gemini-1.5-pro-001”). This method strips version suffixes to get the family name.
25 26 27 28 |
# File 'lib/aidp/providers/gemini.rb', line 25 def self.model_family(provider_model_name) # Strip version suffix: "gemini-1.5-pro-001" → "gemini-1.5-pro" provider_model_name.sub(/-\d+$/, "") end |
.provider_model_name(family_name) ⇒ String
Convert a model family name to the provider’s preferred model name
34 35 36 |
# File 'lib/aidp/providers/gemini.rb', line 34 def self.provider_model_name(family_name) family_name end |
.supports_model_family?(family_name) ⇒ Boolean
Check if this provider supports a given model family
42 43 44 |
# File 'lib/aidp/providers/gemini.rb', line 42 def self.supports_model_family?(family_name) MODEL_PATTERN.match?(family_name) end |
Instance Method Details
#display_name ⇒ Object
75 76 77 |
# File 'lib/aidp/providers/gemini.rb', line 75 def display_name "Google Gemini" end |
#name ⇒ Object
71 72 73 |
# File 'lib/aidp/providers/gemini.rb', line 71 def name "gemini" end |
#send_message(prompt:, session: nil) ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/aidp/providers/gemini.rb', line 79 def (prompt:, session: nil) raise "gemini CLI not available" unless self.class.available? # Smart timeout calculation timeout_seconds = calculate_timeout debug_provider("gemini", "Starting execution", {timeout: timeout_seconds}) debug_log("📝 Sending prompt to gemini...", level: :info) begin command_args = ["--prompt", prompt] result = debug_execute_command("gemini", args: command_args, timeout: timeout_seconds) # Log the results debug_command("gemini", args: command_args, input: nil, output: result.out, error: result.err, exit_code: result.exit_status) if result.exit_status == 0 result.out else debug_error(StandardError.new("gemini failed"), {exit_code: result.exit_status, stderr: result.err}) raise "gemini failed with exit code #{result.exit_status}: #{result.err}" end rescue => e debug_error(e, {provider: "gemini", prompt_length: prompt.length}) raise end end |