commitgpt 0.3.7 → 0.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0f0375fced0367f258ad0a60fdda99b10e11e42c2919b87b1a4e3b7d34c64a39
4
- data.tar.gz: b900f3eb0ad5fe040bbcdc1c928bb1e3843b94a3251141911e3ba28816775fde
3
+ metadata.gz: d812f02e181a923e72486f7ffc5ac1d2e7614bd5eee7194bca7e3a764df7afda
4
+ data.tar.gz: 7195e0edac02853ef4d1dcc7179664beffd023dacdb36c1133c5a01463a0175c
5
5
  SHA512:
6
- metadata.gz: '079b9b9c114a763033df5a4cddd958e51a9c07b0ed9d09216499d8e60ca9f0f1d3f264a3eb24b1566f215f928e91c73d1cd0318bf1ad812705da02a24bddce94'
7
- data.tar.gz: c95285ec608aaa8e5b534d8cc5e6ed2bd3682f460f5b0df7744408521bef5e71f6662b38974e4abf56a7ee4086bb1aed2cf6396ff3d7df61e69f69b16c234e1d
6
+ metadata.gz: 61f5d8a81bc519c7341dde8808656d729c8c3c6c826aa4ecb27779a5b59b3866f8f4fc671424139aa1fa801ce0d1bee14cac903363babafb082f5e3eb354904d
7
+ data.tar.gz: a32a40428daef8ecfe051e39fc0f4cf4040755190c01f0e92eb747aed232b8cc4acabe9ba88b6a9d27b0b7edf666d2da96a07f7d0e75e80ca47adc33b1eb9227
data/README.md CHANGED
@@ -121,10 +121,13 @@ $ aicm setup
121
121
  ```
122
122
 
123
123
  You'll be guided to:
124
- 1. Choose an AI provider (Presets: Cerebras, OpenAI, Ollama, Groq, etc.)
125
- 2. Enter your API Key (stored securely in `config.local.yml`)
126
- 3. Select a model interactively
127
- 4. Set maximum diff length
124
+ 1. Set the model list fetch timeout in seconds (defaults to 30; raise it if a provider is slow to respond)
125
+ 2. Choose an AI provider (Presets: Cerebras, OpenAI, Ollama, Groq, etc.)
126
+ 3. Enter your API Key (stored securely in `config.local.yml`)
127
+ 4. Select a model interactively
128
+ 5. Set maximum diff length
129
+
130
+ The timeout is saved as a top-level `model_fetch_timeout` key in `config.yml` and applies to every provider, including `aicm -p` and `aicm -m`. You can also edit it there directly.
128
131
 
129
132
  **Note:** Please add `~/.config/commitgpt/config.local.yml` to your `.gitignore` if you are syncing your home directory, as it contains your API keys.
130
133
 
data/lib/commitgpt/cli.rb CHANGED
@@ -63,6 +63,7 @@ module CommitGpt
63
63
  shell.say " Format: #{format.capitalize.yellow}"
64
64
  shell.say " Base URL: #{config['base_url']}"
65
65
  shell.say " Diff Len: #{config['diff_len']}"
66
+ shell.say " Timeout: #{CommitGpt::ConfigManager.get_model_fetch_timeout}s"
66
67
  shell.say ''
67
68
  end
68
69
  rescue StandardError
@@ -8,6 +8,9 @@ require_relative 'string'
8
8
  module CommitGpt
9
9
  # Manages configuration files for CommitGPT
10
10
  class ConfigManager
11
+ # Seconds to wait when fetching a provider's model list
12
+ DEFAULT_MODEL_FETCH_TIMEOUT = 30
13
+
11
14
  class << self
12
15
  # Get the config directory path
13
16
  def config_dir
@@ -165,6 +168,23 @@ module CommitGpt
165
168
  save_main_config(main_config)
166
169
  end
167
170
 
171
+ # Get the model list fetch timeout (seconds)
172
+ def get_model_fetch_timeout
173
+ return DEFAULT_MODEL_FETCH_TIMEOUT unless config_exists?
174
+
175
+ main_config = YAML.load_file(main_config_path)
176
+ timeout = main_config['model_fetch_timeout'].to_i
177
+ timeout.positive? ? timeout : DEFAULT_MODEL_FETCH_TIMEOUT
178
+ end
179
+
180
+ # Set the model list fetch timeout (seconds)
181
+ def set_model_fetch_timeout(seconds)
182
+ ensure_config_dir
183
+ main_config = config_exists? ? YAML.load_file(main_config_path) : { 'providers' => [], 'active_provider' => '' }
184
+ main_config['model_fetch_timeout'] = seconds
185
+ save_main_config(main_config)
186
+ end
187
+
168
188
  private
169
189
 
170
190
  # Merge main config with local config (local overrides main)
@@ -19,6 +19,7 @@ module CommitGpt
19
19
  ConfigManager.ensure_config_dir
20
20
  ConfigManager.generate_default_configs unless ConfigManager.config_exists?
21
21
 
22
+ prompt_model_fetch_timeout
22
23
  provider_choice = select_provider
23
24
  configure_provider(provider_choice)
24
25
  end
@@ -245,13 +246,30 @@ module CommitGpt
245
246
  end
246
247
  end
247
248
 
249
+ # Ask how long to wait when fetching the model list, and persist it
250
+ def prompt_model_fetch_timeout
251
+ current = ConfigManager.get_model_fetch_timeout
252
+
253
+ seconds = @prompt.ask('Set the timeout (seconds) for fetching the model list:') do |q|
254
+ q.default current.to_s
255
+ q.convert :int
256
+ q.validate ->(input) { input.to_i.positive? }
257
+ q.messages[:valid?] = 'Timeout must be a positive number of seconds'
258
+ end
259
+
260
+ seconds = current unless seconds.is_a?(Integer) && seconds.positive?
261
+ ConfigManager.set_model_fetch_timeout(seconds)
262
+ seconds
263
+ end
264
+
248
265
  # Fetch models from provider with timeout
249
266
  def fetch_models_with_timeout(base_url, api_key)
267
+ timeout = ConfigManager.get_model_fetch_timeout
250
268
  puts 'Fetching available models...'.gray
251
269
 
252
270
  models = nil
253
271
  begin
254
- Timeout.timeout(5) do
272
+ Timeout.timeout(timeout) do
255
273
  headers = {
256
274
  'Content-Type' => 'application/json',
257
275
  'User-Agent' => "Ruby/#{RUBY_VERSION}"
@@ -269,7 +287,8 @@ module CommitGpt
269
287
  end
270
288
  end
271
289
  rescue Timeout::Error
272
- puts '✖ Connection timeout (5s). Please check your network, base_url, and api_key.'.red
290
+ puts "✖ Connection timeout (#{timeout}s). Please check your network, base_url, and api_key.".red
291
+ puts " Run 'aicm setup' again to raise the timeout.".gray
273
292
  exit(0)
274
293
  rescue StandardError => e
275
294
  puts "✖ Error fetching models: #{e.message}".red
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CommitGpt
4
- VERSION = '0.3.7'
4
+ VERSION = '0.3.9'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: commitgpt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7
4
+ version: 0.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peng Zhang