ipython_interpreter
Module Contents
Classes
A IPython executor that can execute Python scripts in a jupyter manner. |
Functions
|
|
|
|
|
|
|
Attributes
- lagent.actions.ipython_interpreter.START_CODE = Multiline-String
Show Value
""" def input(*args, **kwargs): raise NotImplementedError('Python input() function is disabled.') get_ipython().system = lambda *args: print('Assume we have this package, ! is disabled!') {} """
- exception lagent.actions.ipython_interpreter.TimeoutError
Bases:
ExceptionCommon base class for all non-exit exceptions.
- class lagent.actions.ipython_interpreter.IPythonInterpreter(timeout=20, user_data_dir='ENV', work_dir='./work_dir/tmp_dir', description=None, parser=JsonParser, enable=True)
Bases:
lagent.actions.base_action.BaseActionA IPython executor that can execute Python scripts in a jupyter manner.
- Parameters:
timeout (int) – Upper bound of waiting time for Python script execution. Defaults to 20.
user_data_dir (str, optional) – Specified the user data directory for files loading. If set to ENV, use USER_DATA_DIR environment variable. Defaults to ENV.
work_dir (str, optional) – Specify which directory to save output images to. Defaults to
'./work_dir/tmp_dir'.description (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.enable (bool, optional) – Whether the action is enabled. Defaults to
True.
- static start_kernel()
- initialize()
- reset()
- run(command, timeout=None)
When you send a message containing Python code to python, it will be executed in a stateful Jupyter notebook environment. python will respond with the output of the execution or time out after 60.0 seconds. The drive at ‘/mnt/data’ can be used to save and persist user files. Internet access for this session is disabled. Do not make external web requests or API calls as they will fail.
- Parameters:
command (
str) – Python codetimeout (
Optional[int]) – Upper bound of waiting time for Python script execution.
- Return type:
- lagent.actions.ipython_interpreter.extract_code(text)
- lagent.actions.ipython_interpreter.escape_ansi(line)
- lagent.actions.ipython_interpreter.publish_image_to_local(image_base64, work_dir='./work_dir/tmp_dir')
- Parameters:
image_base64 (str) –
- lagent.actions.ipython_interpreter.get_multiline_input(hint)
- lagent.actions.ipython_interpreter.code_interpreter