#!/usr/bin/env python # -*- coding: utf-8 -*- """ @Time : 2023/5/1 11:59 @Author : alexanderwu @File : const.py """ from pathlib import Path from loguru import logger def get_project_root(): """Search upwards to find the project root directory.""" current_path = Path.cwd() while True: if ( (current_path / ".git").exists() or (current_path / ".project_root").exists() or (current_path / ".gitignore").exists() ): # use metagpt with git clone will land here logger.info(f"PROJECT_ROOT set to {str(current_path)}") return current_path parent_path = current_path.parent if parent_path == current_path: # use metagpt with pip install will land here cwd = Path.cwd() logger.info(f"PROJECT_ROOT set to current working directory: {str(cwd)}") return cwd current_path = parent_path PROJECT_ROOT = get_project_root() DATA_PATH = PROJECT_ROOT / "data" WORKSPACE_ROOT = PROJECT_ROOT / "workspace" PROMPT_PATH = PROJECT_ROOT / "metagpt/prompts" UT_PATH = PROJECT_ROOT / "data/ut" SWAGGER_PATH = UT_PATH / "files/api/" UT_PY_PATH = UT_PATH / "files/ut/" API_QUESTIONS_PATH = UT_PATH / "files/question/" YAPI_URL = "http://yapi.deepwisdomai.com/" TMP = PROJECT_ROOT / "tmp" RESEARCH_PATH = DATA_PATH / "research" TUTORIAL_PATH = DATA_PATH / "tutorial_docx" INVOICE_OCR_TABLE_PATH = DATA_PATH / "invoice_table" SKILL_DIRECTORY = PROJECT_ROOT / "metagpt/skills" MEM_TTL = 24 * 30 * 3600