agentscope.web.gradio.utils module

web ui utils

exception ResetException[source]

Bases: Exception

Custom exception to signal a reset action in the application.

audio2text(audio_path: str) str[source]

Converts audio file at the given path to text using ASR.

check_uuid(uid: str | None) str[source]

Checks whether a UUID is provided or generates a default one.

cycle_dots(text: str, num_dots: int = 3) str[source]

display thinking dots before agent reply

generate_image_from_name(name: str) str[source]

Generates an image based on the hash of the given name.

get_chat_msg(uid: str | None = None) list[source]

Retrieves the next chat message from the queue, if available.

get_player_input(timeout: int | None = None, uid: str | None = None) str[source]

Gets player input from the web UI or command line.

get_reset_msg(uid: str | None = None) None[source]

Retrieves a reset message from the queue, if available.

init_uid_queues() dict[source]

Initializes and returns a dictionary of user-specific queues.

send_msg(msg: str, is_player: bool = False, role: str | None = None, uid: str | None = None, flushing: bool = False, avatar: str | None = None, msg_id: str | None = None) None[source]

Sends a message to the web UI.

send_player_input(msg: str, uid: str | None = None) None[source]

Sends player input to the web UI.

send_reset_msg(uid: str | None = None) None[source]

Sends a reset message to the web UI.

user_input(prefix: str = 'User input: ', timeout: int | None = None) str[source]

get user input