fix(providers): configure RubyLLM API key from ENV before chatting - #2
Merged
Conversation
RubyLLM does not read provider API keys from ENV on its own — its config only defaults log settings from ENV. In a Rails app an initializer calls RubyLLM.configure, but the lingo CLI runs standalone, so translate/quality always failed with 'Missing configuration for <provider>' even when the documented ENV var (e.g. ANTHROPIC_API_KEY) was set. Providers::RubyLLM#chat now fills <provider>_api_key from the matching CREDENTIAL_ENV var when the config value is blank. An explicitly configured key (host-app initializer) always wins.
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
lingo translate/lingo quality --aialways failed standalone withMissing configuration for Anthropic: anthropic_api_keyeven whenANTHROPIC_API_KEYwas set — RubyLLM's config does not default API keys from ENV (only log settings), and nothing in locallingo calledRubyLLM.configure.Providers::RubyLLM#chatnow fills<provider>_api_keyfrom the matchingCREDENTIAL_ENVvar when the config value is blank. A key configured by the host app (e.g. a Rails initializer) always wins.Found while migrating the zazu app off its
bin/translatescript (getzazu/app#2836) — the smoke test of the write path failed on 0.2.1.Test plan
spec/locallingo/providers/ruby_llm_spec.rb: sets key from ENV, doesn't clobber an explicit key, no-ops when ENV is absentbin/lingo translatefills fr/af via Anthropic with onlyANTHROPIC_API_KEYin ENV