ipython_interactive
Module Contents
Classes
Execution status. |
|
Execution result. |
|
An interactive IPython shell for code execution. |
|
An interactive IPython shell for code execution. |
- class lagent.actions.ipython_interactive.Status
Bases:
str,enum.EnumExecution status.
- SUCCESS = 'success'
- FAILURE = 'failure'
- class lagent.actions.ipython_interactive.ExecutionResult
Execution result.
- value: str | None = None
- msg: str | None = None
- class lagent.actions.ipython_interactive.IPythonInteractive(timeout=30, max_out_len=8192, use_signals=True, description=None, parser=JsonParser)
Bases:
lagent.actions.base_action.BaseActionAn interactive IPython shell for code execution.
- 参数:
timeout (int) – Upper bound of waiting time for Python script execution. Defaults to
20.max_out_len (int) – maximum output length. No truncation occurs if negative. Defaults to
2048.use_signals (bool) – whether signals should be used for timing function out or the multiprocessing. Set to
Falsewhen not running in the main thread, e.g. web applications. Defaults toTruedescription (dict) – The description of the action. Defaults to
None.parser (Type[BaseParser]) – The parser class to process the action’s inputs and outputs. Defaults to
JsonParser.
- timeout = 30
- reset()
Clear the context.
- run(command, timeout=None)
Launch an IPython Interactive Shell to execute code.
- 参数:
command (
str) – Python code snippettimeout (
Optional[int]) – timeout for execution. This argument only works in the main thread. Defaults toNone.
- 返回类型:
- exec(code)
Run Python scripts in IPython shell.
- 参数:
code (
str) – code block- 返回:
execution result
- 返回类型:
- static create_shell()
- static extract_code(text)
Extract Python code from markup languages.
- 参数:
text (
str) – Markdown-formatted text- 返回:
Python code
- 返回类型:
str
- static wrap_code_with_timeout(code, timeout)
- 参数:
code (str) –
timeout (int) –
- 返回类型:
str
- class lagent.actions.ipython_interactive.AsyncIPythonInteractive(timeout=30, max_out_len=8192, use_signals=True, description=None, parser=JsonParser)
Bases:
lagent.actions.base_action.AsyncActionMixin,IPythonInteractiveAn interactive IPython shell for code execution.
- 参数:
timeout (int) – Upper bound of waiting time for Python script execution. Defaults to
20.max_out_len (int) – maximum output length. No truncation occurs if negative. Defaults to
2048.use_signals (bool) – whether signals should be used for timing function out or the multiprocessing. Set to
Falsewhen not running in the main thread, e.g. web applications. Defaults toTruedescription (dict) – The description of the action. Defaults to
None.parser (Type[BaseParser]) – The parser class to process the action’s inputs and outputs. Defaults to
JsonParser.
- async run(command, timeout=None)
Launch an IPython Interactive Shell to execute code.
- 参数:
command (
str) – Python code snippettimeout (
Optional[int]) – timeout for execution. This argument only works in the main thread. Defaults toNone.
- 返回类型:
- async exec(code, timeout=None)
Asynchronously run Python scripts in IPython shell.
- 参数:
code (
str) – code blocktimeout (
int) – max waiting time for code execution
- 返回:
execution result
- 返回类型: