kkAIGC/SQLBot
0
1import json2import os3import openai4 5# 构建config.json文件的路径6config_file_path = os.path.join("config", "config.json")7 8# 读取配置文件9with open(config_file_path, "r") as config_file:10 config = json.load(config_file)11 12# 设置环境变量13os.environ["OPENAI_API_KEY"] = config.get("OPENAI_API_KEY")14 15#获取api_key函数16def get_api_key(key):17 if key == '':18 openai.api_key = os.environ.get('OPENAI_API_KEY')19 openai.api_key = key20 