fix: use OPENAI_API_KEY env var consistently (not undefined OPENAI_KEY)#67
Open
FBISiri wants to merge 1 commit into
Open
fix: use OPENAI_API_KEY env var consistently (not undefined OPENAI_KEY)#67FBISiri wants to merge 1 commit into
FBISiri wants to merge 1 commit into
Conversation
The README and the rest of base_agent.py read the OpenAI key from
OPENAI_API_KEY, but load_vision_model() and custom_synonym_expand_fn()
read from os.getenv("OPENAI_KEY"), which is never defined anywhere in
the project. As a result the OpenAI vision model and the synonym
expansion LLM are silently initialized with api_key=None, causing
auth failures at runtime whenever those code paths are used.
Align both call sites to OPENAI_API_KEY.
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.
Problem
base_agent.pyandsynonym_expand/synonym.pyread the OpenAI API key from the environment variableOPENAI_KEY, but that variable is never defined anywhere in the project. The README's setup instructions and the rest ofbase_agent.pyuseOPENAI_API_KEY:README.md(setup):OPENAI_API_KEY="YOUR_API_KEY"base_agent.py:149-150:os.environ["OPENAI_API_KEY"] = os.getenv("OPENAI_API_KEY")But two call sites use the wrong name:
src/memary/agent/base_agent.py:153—OpenAIMultiModal(..., api_key=os.getenv("OPENAI_KEY"))src/memary/synonym_expand/synonym.py:11—OpenAI(openai_api_key=os.getenv("OPENAI_KEY"), ...)Because
OPENAI_KEYis undefined,os.getenv("OPENAI_KEY")returnsNone, so the vision model (gpt-4-vision-preview) and the synonym-expansion LLM are silently initialized withapi_key=Noneand fail with an authentication error at runtime — even when the user has correctly setOPENAI_API_KEYper the README.Fix
Align both call sites to
OPENAI_API_KEY. Two-line, string-only change, no logic change.Verification
grep -rn "OPENAI_KEY" src/before this change shows the two offending sites are the only placesOPENAI_KEY(without_API_) is referenced insrc/; every other reference, and the README, usesOPENAI_API_KEY.