KylinMountain / graphrag-server

添加🚀流式 Web 服务到 GraphRAG,兼容 OpenAI SDK,支持可访问的实体链接🔗,支持建议问题,兼容本地嵌入模型,修复诸多问题。Add streaming web server to GraphRAG, compatible with OpenAI SDK, support accessible entity link, support advice question, compatible with local embedding model, fix lots of issues.
https://microsoft.github.io/graphrag/
MIT License
200 stars 25 forks source link

Fix: Correct API key loading from environment variables (closes #10) #24

Open Theigrams opened 3 months ago

Theigrams commented 3 months ago

Description

This pull request addresses an issue where the llm_params.api_key and text_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 variable GRAPHRAG_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'] and embeddings_config['llm']['api_key']).

Related Issues

This pull request addresses issue #10.

Proposed Changes

Checklist

Additional Notes

No additional notes at this time.

KylinMountain commented 3 months ago

Would you mind to add a further check if api_key is empty, then raise an Exception?

Theigrams commented 3 months ago

Would you mind to add a further check if api_key is empty, then raise an Exception?

Thanks for the suggestion! I've added checks to raise a ValueError if the API keys are empty. Let me know if anything else needs adjustment.

KylinMountain commented 3 months ago

Don't know is it a good idea to raise exception since lots of people use local llm, what's your opinion?