Skip to content

Commit

Permalink
Allow user to initialize agent without calling agentscope.init (#404)
Browse files Browse the repository at this point in the history
  • Loading branch information
DavdGao authored Aug 14, 2024
1 parent 56e6b50 commit c266df4
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/agentscope/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,18 @@ def _save_msg(msg: Msg) -> None:
msg (`Msg`):
The message object to be saved.
"""
logger.log(
LEVEL_SAVE_LOG,
msg.formatted_str(colored=False),
)

logger.log(
LEVEL_SAVE_MSG,
json.dumps(msg, ensure_ascii=False, default=lambda _: None),
)
# TODO: Unified into a manager rather than an indicated attribute here
if hasattr(logger, "chat"):
# Not initialize yet
logger.log(
LEVEL_SAVE_LOG,
msg.formatted_str(colored=False),
)

logger.log(
LEVEL_SAVE_MSG,
json.dumps(msg, ensure_ascii=False, default=lambda _: None),
)


def log_msg(msg: Msg, disable_gradio: bool = False) -> None:
Expand Down

0 comments on commit c266df4

Please sign in to comment.