Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Hotfix] Fix gradio displaying user message twice #317

Merged
merged 1 commit into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/agentscope/agents/user_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,4 @@ def speak(
f"object, got {type(content)} instead.",
)

logger.chat(msg)
logger.chat(msg, disable_gradio=True)
8 changes: 4 additions & 4 deletions src/agentscope/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def _get_speaker_color(speaker: str) -> tuple[str, str]:
def _chat(
message: dict,
*args: Any,
disable_studio: bool = False,
disable_gradio: bool = False,
**kwargs: Any,
) -> None:
"""
Expand Down Expand Up @@ -142,15 +142,15 @@ def _chat(
**kwargs,
)

if hasattr(thread_local_data, "uid") and not disable_studio:
log_studio(message, thread_local_data.uid, **kwargs)
if hasattr(thread_local_data, "uid") and not disable_gradio:
log_gradio(message, thread_local_data.uid, **kwargs)
return

logger.log(LEVEL_DISPLAY_MSG, message, *args, **kwargs)
logger.log(LEVEL_SAVE_LOG, message, *args, **kwargs)


def log_studio(message: dict, uid: str, **kwargs: Any) -> None:
def log_gradio(message: dict, uid: str, **kwargs: Any) -> None:
"""Send chat message to studio.

Args:
Expand Down