diff --git a/_modules/agentscope/constants.html b/_modules/agentscope/constants.html index 2589ff43d..db1c3dc97 100644 --- a/_modules/agentscope/constants.html +++ b/_modules/agentscope/constants.html @@ -105,8 +105,11 @@
_DEFAULT_SUBDIR_CODE = "code"
_DEFAULT_SUBDIR_FILE = "file"
_DEFAULT_SUBDIR_INVOKE = "invoke"
+_DEFAULT_CFG_NAME = ".config"
_DEFAULT_IMAGE_NAME = "image_{}_{}.png"
_DEFAULT_SQLITE_DB_PATH = "agentscope.db"
+
+
# for model wrapper
_DEFAULT_MAX_RETRIES = 3
_DEFAULT_MESSAGES_KEY = "inputs"
diff --git a/_modules/agentscope/utils/tools.html b/_modules/agentscope/utils/tools.html
index 8a161bf67..c3e1b25b4 100644
--- a/_modules/agentscope/utils/tools.html
+++ b/_modules/agentscope/utils/tools.html
@@ -125,9 +125,15 @@ Source code for agentscope.utils.tools
-def _get_timestamp(format_: str = "%Y-%m-%d %H:%M:%S") -> str:
+def _get_timestamp(
+ format_: str = "%Y-%m-%d %H:%M:%S",
+ time: datetime.datetime = None,
+) -> str:
"""Get current timestamp."""
- return datetime.datetime.now().strftime(format_)
+ if time is None:
+ return datetime.datetime.now().strftime(format_)
+ else:
+ return time.strftime(format_)
@@ -239,9 +245,20 @@ Source code for agentscope.utils.tools
return False
-def _generate_random_code(length: int = 6) -> str:
+def _generate_random_code(
+ length: int = 6,
+ uppercase: bool = True,
+ lowercase: bool = True,
+ digits: bool = True,
+) -> str:
"""Get random code."""
- characters = string.ascii_letters + string.digits
+ characters = ""
+ if uppercase:
+ characters += string.ascii_uppercase
+ if lowercase:
+ characters += string.ascii_lowercase
+ if digits:
+ characters += string.digits
return "".join(secrets.choice(characters) for i in range(length))