agentscope.utils.common module
Common utils.
- agentscope.utils.common.timer(seconds: int | float | None = None) Generator [source]
A context manager that limits the execution time of a code block to a given number of seconds. The implementation of this contextmanager are borrowed from https://github.com/openai/human-eval/blob/master/human_eval/execution.py
Note
This function only works in Unix and MainThread, since signal.setitimer is only available in Unix.
- agentscope.utils.common.create_tempdir() Generator [source]
A context manager that creates a temporary directory and changes the current working directory to it. The implementation of this contextmanager are borrowed from https://github.com/openai/human-eval/blob/master/human_eval/execution.py
- agentscope.utils.common.to_openai_dict(item: dict) dict [source]
Convert Msg to dict for OpenAI API.