Files
general_tools/src/config/load_config.py
T
2025-12-28 16:59:29 +08:00

22 lines
687 B
Python

import json
import os
from pathlib import Path
from langchain_openai import ChatOpenAI
from pydantic import SecretStr
PROJECT_PATH = Path(__file__).parent.parent.parent.absolute()
if os.path.exists(os.path.join(PROJECT_PATH, "config", "config_local.json")):
CONFIG_PATH = os.path.join(PROJECT_PATH, "config", "config_local.json")
elif os.path.exists(os.path.join(PROJECT_PATH, "config", "config.json")):
CONFIG_PATH = os.path.join(PROJECT_PATH, "config", "config.json")
else:
raise FileNotFoundError('Unable to locate config file, check src/config/config.json')
with open(CONFIG_PATH, 'r', encoding='utf-8') as config_file:
project_config = json.load(config_file)