forked from lingyuzeng/agent
langgraph adapter
This commit is contained in:
22
langgraph_qwen/utils.py
Normal file
22
langgraph_qwen/utils.py
Normal file
@@ -0,0 +1,22 @@
|
||||
_DOTENV_LOADED = False
|
||||
|
||||
|
||||
def ensure_env_loaded() -> None:
|
||||
global _DOTENV_LOADED
|
||||
if _DOTENV_LOADED:
|
||||
return
|
||||
try:
|
||||
# Lazy import to avoid hard failure if not installed
|
||||
from dotenv import load_dotenv, find_dotenv # type: ignore
|
||||
|
||||
path = find_dotenv(usecwd=True)
|
||||
if path:
|
||||
load_dotenv(dotenv_path=path, override=False)
|
||||
else:
|
||||
# Fall back to default discovery in CWD
|
||||
load_dotenv(override=False)
|
||||
except Exception:
|
||||
# Silently ignore if python-dotenv is not available or errors out
|
||||
pass
|
||||
_DOTENV_LOADED = True
|
||||
|
||||
Reference in New Issue
Block a user