ask-llm-providers 0.8.3 → 0.8.5

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: 5d5b33d4106b1ff85f594f7651b95cfb69bde7f1aaa35e7050fd9b102014d52f
4
- data.tar.gz: 25740a685dfff7b3385596483a4134733b56868492687eb220d02fbcbeae58fe
3
+ metadata.gz: a27af477a1da8a77d488c5a76e7de465cbf31e9f76baa1716198a08fe0c99842
4
+ data.tar.gz: a643f3c0767f7d4653ad353bf9c4e9afc2e71f90ce3cf23c0536fae7200cab2f
5
5
  SHA512:
6
- metadata.gz: b6241b99f318212baca48ad6be2956c82e56ea403773e0b998777019f1df23387642d08b0d4fb1428d649569321bde1989bd05041b0981e08d78334897e9b6fc
7
- data.tar.gz: 66257980209fd5ca113cedf3c8ad30f79e16b1f6e3db1af4f3527aec77527976447b1702ee21fd525322a355d7af36bbae9876c29e9f9ae1ec95f351ddfe1bf9
6
+ metadata.gz: e3ce29cf115e4d787ad8d3dc4ef8af24a2255f9bbbbf7c7a3e9cc794e50241de4ab8e2585d1dabb32e25e5354ec152519a0bf9159a7f5296c1388211b87ba61f
7
+ data.tar.gz: d04f1e5e22d99dafeced058754410e184a3098711db75cf3f4fbfb1eb52b9cfdfa5a153d36e3074f4054bbf624e0625fb10f690329220b103d6a52bfe1a9ea18
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## [0.8.5] — 2026-07-18
2
+
3
+ ### Fixed
4
+
5
+ - **`OpenAICompatible#normalize_compat_config` now resolves credentials from `api_key_env` via `Ask::Auth`** — Previously the method only checked explicit config keys and environment variables. Now it also calls `Ask::Auth.resolve` using the downcased `api_key_env` name (e.g., `OPENCODE_API_KEY` → `:opencode_api_key` → resolves through Rails credentials at `opencode.api_key`, env, file, database, or OAuth). This fixes credential resolution for all 26 OpenAI-compatible providers when the API key is stored in Rails credentials, the ask credentials file, or any provider in the auth chain — not just environment variables.
6
+
7
+ ## [0.8.4] — 2026-07-18
8
+
9
+ ### Fixed
10
+
11
+ - **`normalize_config` (OpenAI) and `normalize_compat_config` (OpenAICompatible) — Config object handling** — `Chat#provider_config` creates an `Ask::LLM::Config` object, but both methods previously bailed out with `return config unless config.is_a?(Hash)`, allowing the Config object to pass through without API key resolution. Now they call `config.to_h` when the object responds to it before the Hash guard, ensuring env vars like `OPENCODE_API_KEY` are properly resolved for all OpenAI-compatible providers. Fixes auth for all 20+ OpenAI-compatible providers when config arrives as a Config object.
12
+
1
13
  ## [0.8.1] — 2026-07-17
2
14
 
3
15
  ### Added
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ask
4
4
  module LLM
5
- VERSION = "0.8.3"
5
+ VERSION = "0.8.5"
6
6
  end
7
7
  end
@@ -166,6 +166,7 @@ module Ask
166
166
  end
167
167
 
168
168
  def normalize_config(config)
169
+ config = config.to_h if config.respond_to?(:to_h)
169
170
  return config if !config.is_a?(Hash)
170
171
 
171
172
  slug = self.class.slug
@@ -71,6 +71,7 @@ module Ask
71
71
  private
72
72
 
73
73
  def normalize_compat_config(config)
74
+ config = config.to_h if config.respond_to?(:to_h)
74
75
  return config unless config.is_a?(Hash)
75
76
 
76
77
  slug = self.class.slug
@@ -78,7 +79,8 @@ module Ask
78
79
  config[:"#{slug}_api_key"] ||
79
80
  ENV[@compat_cfg[:api_key_env].to_s] ||
80
81
  (ENV[@compat_cfg[:alternate_env].to_s] if @compat_cfg[:alternate_env]) ||
81
- ENV["#{slug.upcase}_API_KEY"]
82
+ ENV["#{slug.upcase}_API_KEY"] ||
83
+ resolve_credential_from_env_name
82
84
 
83
85
  base_url = config[:base_url] || config["base_url"] ||
84
86
  ENV["#{slug.upcase}_API_BASE"] ||
@@ -86,6 +88,28 @@ module Ask
86
88
 
87
89
  Ask::LLM::Config.new(api_key:, base_url:)
88
90
  end
91
+
92
+ # Uses the registry's +api_key_env+ as a credential name for
93
+ # Ask::Auth.resolve. This lets users store their API key under the
94
+ # canonical credential name (e.g., +opencode.api_key+ in Rails
95
+ # credentials) while using a specific variant provider
96
+ # (e.g., +opencode_go+) whose slug differs from the base name.
97
+ #
98
+ # For +opencode_go+ with +api_key_env: "OPENCODE_API_KEY"+,
99
+ # this resolves +:opencode_api_key+, which checks:
100
+ # ENV["OPENCODE_API_KEY"] →
101
+ # Rails.application.credentials.opencode.api_key
102
+ #
103
+ # @return [String, nil]
104
+ def resolve_credential_from_env_name
105
+ env_name = @compat_cfg[:api_key_env]
106
+ return nil unless env_name
107
+
108
+ cred_name = env_name.to_s.downcase
109
+ Ask::Auth.resolve(cred_name.to_sym)
110
+ rescue StandardError
111
+ nil
112
+ end
89
113
  end
90
114
  end
91
115
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ask-llm-providers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.3
4
+ version: 0.8.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kaka Ruto