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 +4 -4
- data/README.md +7 -4
- data/lib/commitgpt/cli.rb +1 -0
- data/lib/commitgpt/config_manager.rb +20 -0
- data/lib/commitgpt/setup_wizard.rb +21 -2
- data/lib/commitgpt/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d812f02e181a923e72486f7ffc5ac1d2e7614bd5eee7194bca7e3a764df7afda
|
|
4
|
+
data.tar.gz: 7195e0edac02853ef4d1dcc7179664beffd023dacdb36c1133c5a01463a0175c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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.
|
|
125
|
-
2.
|
|
126
|
-
3.
|
|
127
|
-
4.
|
|
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(
|
|
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
|
|
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
|
data/lib/commitgpt/version.rb
CHANGED