diff --git a/src/agentscope/constants.py b/src/agentscope/constants.py index b5e770b03..5a5ab1ab9 100644 --- a/src/agentscope/constants.py +++ b/src/agentscope/constants.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- """ Some constants used in the project""" +import os from numbers import Number from enum import IntEnum @@ -19,7 +20,16 @@ _DEFAULT_SUBDIR_CODE = "code" _DEFAULT_SUBDIR_FILE = "file" _DEFAULT_SUBDIR_INVOKE = "invoke" -_DEFAULT_CACHE_DIR = str(Path.home() / ".cache" / "agentscope") +_DEFAULT_CACHE_DIR = str( + Path( + os.environ.get( + "AS_HOME_PATH", + str(Path.home()), + ), + ) + / ".cache" + / "agentscope", +) _DEFAULT_CFG_NAME = ".config" _DEFAULT_IMAGE_NAME = "image_{}_{}.png" _DEFAULT_SQLITE_DB_NAME = "agentscope.db" diff --git a/src/agentscope/studio/_app.py b/src/agentscope/studio/_app.py index 81ed58b61..06226944d 100644 --- a/src/agentscope/studio/_app.py +++ b/src/agentscope/studio/_app.py @@ -27,6 +27,7 @@ from flask_socketio import SocketIO, join_room, leave_room from ..constants import ( + _DEFAULT_CACHE_DIR, _DEFAULT_SUBDIR_CODE, _DEFAULT_SUBDIR_INVOKE, FILE_SIZE_LIMIT, @@ -44,7 +45,7 @@ _app = Flask(__name__) # Set the cache directory -_cache_dir = Path.home() / ".cache" / "agentscope-studio" +_cache_dir = Path(_DEFAULT_CACHE_DIR) / "studio" _cache_db = _cache_dir / "agentscope.db" os.makedirs(str(_cache_dir), exist_ok=True)