Fix: Correct API key loading from environment variables (closes #10) #24
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.
Description
This pull request addresses an issue where the
llm_params.api_key
andtext_embedding.llm.api_key
variables were being incorrectly set to the literal string"<API_KEY>"
due to a lack of proper validation after reading the environment variableGRAPHRAG_API_KEY
. The issue was identified in lines 56 and 58 of the code. The proposed fix includes adding conditional checks to ensure that if the API keys are set to"<API_KEY>"
, they are replaced with the correct values from the respective configuration files (llm_config['api_key']
andembeddings_config['llm']['api_key']
).Related Issues
This pull request addresses issue #10.
Proposed Changes
llm_params.api_key
to replace"<API_KEY>"
with the correct value fromllm_config['api_key']
.text_embedding.llm.api_key
to replace"<API_KEY>"
with the correct value fromembeddings_config['llm']['api_key']
.llm_params.api_key
ortext_embedding.llm.api_key
is empty after loading. If either is empty, a ValueError is raised to notify the user.Checklist
Additional Notes
No additional notes at this time.