[Bug]: OpenAI API key changes not reflected across multiple calls #1828
Labels
backlog
We've confirmed some action is needed on this and will plan it
enhancement
New feature or request
Do you need to file an issue?
Describe the bug
I am using graphrag in a FastAPI backend service where a request can create a new custom index. The OpenAI API keys appear to be cached in memory across requests. Even though configurations are set dynamically from a template each time (with a possible new key), and the correct key is present just before entering
build_index
function, the requests still use an outdated key. This appears in the following scenario: First, an incorrect api key is used, which results in an 401 error as expected. The next time a correct key is used, which still results in the same error showing an preview of the previous incorrect key. Logging the settings going intobuild_index
shows the intended key.My configuration explicitly sets caching to "none", but the documentation is unclear on whether this affects the overall caching behavior of the LLM client. Restarting the FastAPI server clears the issue, suggesting that the key is being held in memory rather than being refreshed dynamically. This might also be related to the use of the fnllm library as far as I understand.
Steps to reproduce
No response
Expected Behavior
No response
GraphRAG Config Used
# Paste your config here
Logs and screenshots
No response
Additional Information
The text was updated successfully, but these errors were encountered: