2023-06-30 17:10:48 +08:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
"""
|
|
|
|
|
@Time : 2023/5/1 11:59
|
|
|
|
|
@Author : alexanderwu
|
|
|
|
|
@File : const.py
|
|
|
|
|
"""
|
|
|
|
|
from pathlib import Path
|
2023-11-08 19:42:30 +08:00
|
|
|
from loguru import logger
|
2023-06-30 17:10:48 +08:00
|
|
|
|
|
|
|
|
def get_project_root():
|
2023-07-27 08:40:32 -05:00
|
|
|
"""Search upwards to find the project root directory."""
|
2023-06-30 17:10:48 +08:00
|
|
|
current_path = Path.cwd()
|
|
|
|
|
while True:
|
2023-09-18 12:46:15 +08:00
|
|
|
if (
|
|
|
|
|
(current_path / ".git").exists()
|
|
|
|
|
or (current_path / ".project_root").exists()
|
|
|
|
|
or (current_path / ".gitignore").exists()
|
|
|
|
|
):
|
2023-11-08 19:42:30 +08:00
|
|
|
# use metagpt with git clone will land here
|
2023-11-09 16:51:20 +08:00
|
|
|
logger.info(f"PROJECT_ROOT set to {str(current_path)}")
|
2023-06-30 17:10:48 +08:00
|
|
|
return current_path
|
|
|
|
|
parent_path = current_path.parent
|
|
|
|
|
if parent_path == current_path:
|
2023-11-08 19:42:30 +08:00
|
|
|
# use metagpt with pip install will land here
|
|
|
|
|
cwd = Path.cwd()
|
2023-11-09 16:51:20 +08:00
|
|
|
logger.info(f"PROJECT_ROOT set to current working directory: {str(cwd)}")
|
2023-11-08 19:42:30 +08:00
|
|
|
return cwd
|
2023-06-30 17:10:48 +08:00
|
|
|
current_path = parent_path
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PROJECT_ROOT = get_project_root()
|
2023-09-18 12:46:15 +08:00
|
|
|
DATA_PATH = PROJECT_ROOT / "data"
|
|
|
|
|
WORKSPACE_ROOT = PROJECT_ROOT / "workspace"
|
|
|
|
|
PROMPT_PATH = PROJECT_ROOT / "metagpt/prompts"
|
|
|
|
|
UT_PATH = PROJECT_ROOT / "data/ut"
|
2023-06-30 17:10:48 +08:00
|
|
|
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/"
|
2023-09-18 12:46:15 +08:00
|
|
|
TMP = PROJECT_ROOT / "tmp"
|
2023-08-08 22:59:26 +08:00
|
|
|
RESEARCH_PATH = DATA_PATH / "research"
|
2023-09-06 14:43:24 +08:00
|
|
|
TUTORIAL_PATH = DATA_PATH / "tutorial_docx"
|
2023-10-10 14:26:03 +08:00
|
|
|
INVOICE_OCR_TABLE_PATH = DATA_PATH / "invoice_table"
|
2023-07-24 09:44:03 +08:00
|
|
|
|
2023-09-18 12:46:15 +08:00
|
|
|
SKILL_DIRECTORY = PROJECT_ROOT / "metagpt/skills"
|
|
|
|
|
|
2023-07-24 09:44:03 +08:00
|
|
|
MEM_TTL = 24 * 30 * 3600
|