Native data AI application framework based on AWEL+AGENT (#1152)

Co-authored-by: Fangyin Cheng <staneyffer@gmail.com>
Co-authored-by: lcx01800250 <lcx01800250@alibaba-inc.com>
Co-authored-by: licunxing <864255598@qq.com>
Co-authored-by: Aralhi <xiaoping0501@gmail.com>
Co-authored-by: xuyuan23 <643854343@qq.com>
Co-authored-by: aries_ckt <916701291@qq.com>
Co-authored-by: hzh97 <2976151305@qq.com>
This commit is contained in:
明天
2024-02-07 17:43:27 +08:00
committed by GitHub
parent dbb9ac83b1
commit d5afa6e206
328 changed files with 22606 additions and 3282 deletions

62
dbgpt/util/dbgpts/base.py Normal file
View File

@@ -0,0 +1,62 @@
import hashlib
import logging
import os
import sys
from pathlib import Path
logger = logging.getLogger(__name__)
_ABS_ROOT_PATH = os.path.dirname(
os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
)
DEFAULT_DBGPTS_DIR = Path.home() / ".dbgpts"
DBGPTS_HOME = os.getenv("DBGPTS_HOME", str(DEFAULT_DBGPTS_DIR))
DBGPTS_REPO_HOME = os.getenv("DBGPTS_REPO_HOME", str(DEFAULT_DBGPTS_DIR / "repos"))
DEFAULT_REPO_MAP = {
"eosphoros/dbgpts": "https://github.com/eosphoros-ai/dbgpts.git",
"fangyinc/dbgpts": "https://github.com/fangyinc/dbgpts.git",
}
DEFAULT_PACKAGES = ["agents", "apps", "operators", "workflow"]
DEFAULT_PACKAGE_TYPES = ["agent", "app", "operator", "flow"]
INSTALL_METADATA_FILE = "install_metadata.toml"
DBGPTS_METADATA_FILE = "dbgpts.toml"
def _get_env_sig() -> str:
"""Get a unique signature for the current Python environment."""
py_path = os.path.join(os.path.dirname(sys.executable), "python")
env_path = f"{_ABS_ROOT_PATH}_{py_path}"
md5_hash = hashlib.md5()
md5_hash.update(env_path.encode("utf-8"))
return md5_hash.hexdigest()
def _print_path(path: str | Path) -> str:
str_path = str(path)
if str_path.startswith(str(Path.home())):
str_path = str_path.replace(str(Path.home()), "~")
return str_path
def get_repo_path(repo: str) -> str:
"""Get the path of the repo
Args:
repo (str): The name of the repo
Returns:
str: The path of the repo
"""
repo_group, repo_name = repo.split("/")
return str(Path(DBGPTS_REPO_HOME) / repo_group / repo_name)
ENV_SIG = _get_env_sig()
# The directory where the dbgpts package is installed
INSTALL_DIR = Path(DBGPTS_HOME) / "packages" / ENV_SIG
os.makedirs(DBGPTS_REPO_HOME, exist_ok=True)
os.makedirs(INSTALL_DIR, exist_ok=True)