Add SANDBOX_WORKSPACE_DIR into config (#1266)

* Add SANDBOX_WORKSPACE_DIR into config

* Add SANDBOX_WORKSPACE_DIR into config

* fix occurence of /workspace
This commit is contained in:
Xingyao Wang 2024-04-22 03:17:10 +08:00 committed by GitHub
parent 0e572c3e41
commit dffbeec45a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 10 additions and 5 deletions

View File

@ -125,7 +125,8 @@ class MonologueAgent(Agent):
def _initialize(self, task: str):
"""
Utilizes the INITIAL_THOUGHTS list to give the agent a context for it's capabilities and how to navigate the /workspace.
Utilizes the INITIAL_THOUGHTS list to give the agent a context for it's capabilities
and how to navigate the WORKSPACE_MOUNT_PATH_IN_SANDBOX in `config` (e.g., /workspace by default).
Short circuited to return when already initialized.
Parameters:

View File

@ -13,6 +13,7 @@ from opendevin.observation import (
CmdOutputObservation,
)
from opendevin.exceptions import LLMOutputError
from opendevin import config
ACTION_PROMPT = """
You're a thoughtful robot. Your main task is this:
@ -58,7 +59,7 @@ actions are all "think" actions, you should consider taking a different action.
Notes:
* your environment is Debian Linux. You can install software with `apt`
* your working directory will not change, even if you run `cd`. All commands will be run in the `/workspace` directory.
* your working directory will not change, even if you run `cd`. All commands will be run in the `%(WORKSPACE_MOUNT_PATH_IN_SANDBOX)s` directory.
* don't run interactive commands, or commands that don't return (e.g. `node server.js`). You may run commands in the background (e.g. `node server.js &`)
What is your next thought or action? Again, you must reply with JSON, and only with JSON.
@ -145,6 +146,7 @@ def get_request_action_prompt(
'monologue': json.dumps(thoughts, indent=2),
'background_commands': bg_commands_message,
'hint': hint,
'WORKSPACE_MOUNT_PATH_IN_SANDBOX': config.get('WORKSPACE_MOUNT_PATH_IN_SANDBOX'),
}

View File

@ -13,6 +13,7 @@ DEFAULT_CONFIG: dict = {
ConfigType.LLM_BASE_URL: None,
ConfigType.WORKSPACE_BASE: os.getcwd(),
ConfigType.WORKSPACE_MOUNT_PATH: None,
ConfigType.WORKSPACE_MOUNT_PATH_IN_SANDBOX: '/workspace',
ConfigType.WORKSPACE_MOUNT_REWRITE: None,
ConfigType.LLM_MODEL: 'gpt-3.5-turbo-1106',
ConfigType.SANDBOX_CONTAINER_IMAGE: 'ghcr.io/opendevin/sandbox',

View File

@ -21,7 +21,7 @@ InputType = namedtuple('InputType', ['content'])
OutputType = namedtuple('OutputType', ['content'])
CONTAINER_IMAGE = config.get(ConfigType.SANDBOX_CONTAINER_IMAGE)
SANDBOX_WORKSPACE_DIR = '/workspace'
SANDBOX_WORKSPACE_DIR = config.get(ConfigType.WORKSPACE_MOUNT_PATH_IN_SANDBOX)
# FIXME: On some containers, the devin user doesn't have enough permission, e.g. to install packages
# How do we make this more flexible?

View File

@ -22,7 +22,7 @@ from opendevin.exceptions import SandboxInvalidBackgroundCommandError
InputType = namedtuple('InputType', ['content'])
OutputType = namedtuple('OutputType', ['content'])
SANDBOX_WORKSPACE_DIR = '/workspace'
SANDBOX_WORKSPACE_DIR = config.get(ConfigType.WORKSPACE_MOUNT_PATH_IN_SANDBOX)
CONTAINER_IMAGE = config.get(ConfigType.SANDBOX_CONTAINER_IMAGE)
@ -170,7 +170,7 @@ class DockerSSHBox(Sandbox):
self.ssh.sendline("bind 'set enable-bracketed-paste off'")
self.ssh.prompt()
# cd to workspace
self.ssh.sendline('cd /workspace')
self.ssh.sendline(f'cd {SANDBOX_WORKSPACE_DIR}')
self.ssh.prompt()
def get_exec_cmd(self, cmd: str) -> List[str]:

View File

@ -7,6 +7,7 @@ class ConfigType(str, Enum):
WORKSPACE_BASE = 'WORKSPACE_BASE'
WORKSPACE_MOUNT_PATH = 'WORKSPACE_MOUNT_PATH'
WORKSPACE_MOUNT_REWRITE = 'WORKSPACE_MOUNT_REWRITE'
WORKSPACE_MOUNT_PATH_IN_SANDBOX = 'WORKSPACE_MOUNT_PATH_IN_SANDBOX'
LLM_MODEL = 'LLM_MODEL'
SANDBOX_CONTAINER_IMAGE = 'SANDBOX_CONTAINER_IMAGE'
RUN_AS_DEVIN = 'RUN_AS_DEVIN'