Closed EvelynBai closed 1 week ago
@EvelynBai
In this case you have to set USE_CUSTOMIZED_GRAPHRAG_SETTING=true
and edit your custom model in settings.yaml.example
https://github.com/Cinnamon/kotaemon#setup-graphrag
Currently this is an issue of GraphRAG not respecting the GRAPHRAG_LLM_MODEL
and GRAPHRAG_EMBEDDING_MODEL
but using default model names in the config file.
We will figure out how to make the setup more seamlessly in the future with custom GraphRAG implementation.
The reason for this problem is that the graphrag index is called through subprocess. Under this calling method, the environment variables in .env cannot be passed to the command in the subprocess.
here is my solution for you reference.
# get env values from .env file
env={"GRAPHRAG_LLM_MODEL", config("GRAPHRAG_LLM_MODEL", default="gpt-4-turbo-preview")}
# Run the command and stream stdout
with subprocess.Popen(command, stdout=subprocess.PIPE, text=True, env=env) as process:
if process.stdout:
for line in process.stdout:
yield Document(channel="debug", text=line)
@EvelynBai In this case you have to set
USE_CUSTOMIZED_GRAPHRAG_SETTING=true
and edit your custom model insettings.yaml.example
https://github.com/Cinnamon/kotaemon#setup-graphragCurrently this is an issue of GraphRAG not respecting the
GRAPHRAG_LLM_MODEL
andGRAPHRAG_EMBEDDING_MODEL
but using default model names in the config file.We will figure out how to make the setup more seamlessly in the future with custom GraphRAG implementation.
Thanks! This solved my problem.
The reason for this problem is that the graphrag index is called through subprocess. Under this calling method, the environment variables in .env cannot be passed to the command in the subprocess.
here is my solution for you reference.
- Prepare a dict
- Write the environment variables that need to be passed to graphrag in the dict, and you can get its value from .env
- In the subprocess, pass the environment variables in through the env parameter
# get env values from .env file env={"GRAPHRAG_LLM_MODEL", config("GRAPHRAG_LLM_MODEL", default="gpt-4-turbo-preview")} # Run the command and stream stdout with subprocess.Popen(command, stdout=subprocess.PIPE, text=True, env=env) as process: if process.stdout: for line in process.stdout: yield Document(channel="debug", text=line)
I'll try it out. Thank you!
Description
I have reviewed previous issues and took steps like "export $(cat .env | xargs)", "dotenv run -- python app.py". However the GraphRAG still used gpt-4-turbo-preview llm instead of my settings GRAPHRAG_LLM_MODEL=gpt-4o-mini-2024-07-18 in .env file.
My .env file: `OPENAI_API_BASE=https://api.openai.com/v1 OPENAI_API_KEY=
OPENAI_CHAT_MODEL=gpt-4o-mini-2024-07-18
OPENAI_EMBEDDINGS_MODEL=text-embedding-3-small
GRAPHRAG_API_KEY=
GRAPHRAG_LLM_MODEL=gpt-4o-mini-2024-07-18
GRAPHRAG_EMBEDDING_MODEL=text-embedding-3-small
GRAPHRAG_LLM_REQUEST_TIMEOUT=1800.0`
indexing-engine.log: 03:26:45,442 graphrag.index.cli INFO Using default configuration: { "llm": { "api_key": "==== REDACTED ====", "type": "openai_chat", "model": "gpt-4-turbo-preview", "max_tokens": 4000, "temperature": 0.0, "top_p": 1.0, "n": 1, "request_timeout": 1800.0, "api_base": null, "api_version": "2024-02-15-preview", "proxy": null, "cognitive_services_endpoint": null, "deployment_name": null, "model_supports_json": true, "tokens_per_minute": 0, "requests_per_minute": 0, "max_retries": 10, "max_retry_wait": 10.0, "sleep_on_rate_limit_recommendation": true, "concurrent_requests": 25 } ... }`
Reproduction steps
Screenshots
No response
Logs
Browsers
Chrome
OS
Linux
Additional information
No response