Skip to content

Commit

Permalink
Fix text display in logger (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
pan-x-c authored Mar 13, 2024
1 parent 0b4bf85 commit e489305
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/agentscope/agents/dict_dialog_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def reply(self, x: dict = None) -> dict:
).raw

# logging raw messages in debug mode
logger.debug(json.dumps(response, indent=4))
logger.debug(json.dumps(response, indent=4, ensure_ascii=False))

# In this agent, if the response is a dict, we treat "speak" as a
# special key, which represents the text to be spoken
Expand Down
7 changes: 5 additions & 2 deletions src/agentscope/models/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def __str__(self) -> str:
"image_urls": self.image_urls,
"raw": self.raw,
}
return json.dumps(serialized_fields, indent=4)
return json.dumps(serialized_fields, indent=4, ensure_ascii=False)


def _response_parse_decorator(
Expand Down Expand Up @@ -223,7 +223,10 @@ def __init__(self, config_name: str, **kwargs: Any) -> None:
"""
self.config_name = config_name
logger.info(f"Initialize model [{config_name}]")
logger.debug(f"[{config_name}]:\n {json.dumps(kwargs, indent=2)}")
logger.debug(
f"[{config_name}]:\n"
f"{json.dumps(kwargs, indent=2, ensure_ascii=False)}",
)

def __call__(self, *args: Any, **kwargs: Any) -> ModelResponse:
"""Processing input with the model."""
Expand Down
7 changes: 6 additions & 1 deletion src/agentscope/utils/logging_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,12 @@ def _chat(message: Union[str, dict], *args: Any, **kwargs: Any) -> None:
<content>".
"""
# Save message into file
logger.log(LEVEL_CHAT_SAVE, json.dumps(message), *args, **kwargs)
logger.log(
LEVEL_CHAT_SAVE,
json.dumps(message, ensure_ascii=False),
*args,
**kwargs,
)

# Print message in terminal with specific format
if isinstance(message, dict):
Expand Down

0 comments on commit e489305

Please sign in to comment.