加载配置文件
()
| 10 | from recipe_ai_agent import LLMRecipeAgent, RecipeKnowledgeGraphBuilder |
| 11 | |
| 12 | def load_config(): |
| 13 | """加载配置文件""" |
| 14 | config_file = "config.json" |
| 15 | if os.path.exists(config_file): |
| 16 | with open(config_file, 'r', encoding='utf-8') as f: |
| 17 | return json.load(f) |
| 18 | else: |
| 19 | print("警告: 未找到config.json配置文件,将使用默认配置") |
| 20 | return { |
| 21 | "openai": { |
| 22 | "api_key": "", |
| 23 | "base_url": "https://api.openai.com/v1" |
| 24 | }, |
| 25 | "output": { |
| 26 | "format": "neo4j", |
| 27 | "directory": "./ai_output" |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | def setup_api_key(): |
| 32 | """设置API密钥""" |
no outgoing calls