diff --git a/src/agentscope/logging.py b/src/agentscope/logging.py index 498c007b2..150bad5bb 100644 --- a/src/agentscope/logging.py +++ b/src/agentscope/logging.py @@ -175,7 +175,7 @@ def _level_format(record: dict) -> str: if record["level"].name == LEVEL_SAVE_LOG: return "{message}\n" else: - return _DEFAULT_LOG_FORMAT + return _DEFAULT_LOG_FORMAT + "\n" def setup_logger( @@ -192,6 +192,9 @@ def setup_logger( `"DEBUG"`, `"INFO"`, `"SUCCESS"`, `"WARNING"`, `"ERROR"`, `"CRITICAL"`. """ + # set logging level + logger.remove() + # avoid reinit in subprocess if not hasattr(logger, "chat"): # add chat function for logger @@ -201,8 +204,6 @@ def setup_logger( logger.level(LEVEL_SAVE_MSG, no=53) logger.chat = log_msg - # set logging level - logger.remove() # standard output for all logging except chat logger.add( sys.stdout, diff --git a/src/agentscope/service/service_toolkit.py b/src/agentscope/service/service_toolkit.py index 8f0013bda..f66d64fca 100644 --- a/src/agentscope/service/service_toolkit.py +++ b/src/agentscope/service/service_toolkit.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- """Service Toolkit for service function usage.""" -import collections.abc import json from functools import partial import inspect @@ -40,7 +39,10 @@ def _get_type_str(cls: Any) -> Optional[Union[str, list]]: # Typing class if cls.__origin__ is Union: type_str = [_get_type_str(_) for _ in get_args(cls)] - elif cls.__origin__ is collections.abc.Sequence: + clean_type_str = [_ for _ in type_str if _ != "null"] + if len(clean_type_str) == 1: + type_str = clean_type_str[0] + elif cls.__origin__ in [list, tuple]: type_str = "array" else: type_str = str(cls.__origin__) @@ -52,7 +54,7 @@ def _get_type_str(cls: Any) -> Optional[Union[str, list]]: type_str = "number" elif cls is bool: type_str = "boolean" - elif cls is collections.abc.Sequence: + elif cls in [list, tuple]: type_str = "array" elif cls is None.__class__: type_str = "null" @@ -511,9 +513,9 @@ def bing_search(query: str, api_key: str, num_results: int=10): docstring = parse(service_func.__doc__) # Function description - func_description = ( - docstring.short_description or docstring.long_description - ) + short_description = docstring.short_description or "" + long_description = docstring.long_description or "" + func_description = "\n\n".join([short_description, long_description]) # The arguments that requires the agent to specify # to support class method, the self args are deprecated @@ -669,9 +671,9 @@ def bing_search(query: str, api_key: str, num_results: int=10): docstring = parse(service_func.__doc__) # Function description - func_description = ( - docstring.short_description or docstring.long_description - ) + short_description = docstring.short_description or "" + long_description = docstring.long_description or "" + func_description = "\n".join([short_description, long_description]) # The arguments that requires the agent to specify # we remove the self argument, for class methods