mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
* Some improvements to prompts, some better exception handling for various file IO errors, added timeout and max return token configurations for the LLM api. * More monologue prompt improvements * Dynamically set username provided in prompt. * Remove absolute paths from llm prompts, fetch working directory from sandbox when resolving paths in fileio operations, add customizable timeout for bash commands, mention said timeout in llm prompt. * Switched ssh_box to disabling tty echo and removed the logic attempting to delete it from the response afterwards, fixed get_working_directory for ssh_box. * Update prompts in integration tests to match monologue agent changes. * Minor tweaks to make merge easier. * Another minor prompt tweak, better invalid json handling. * Fix lint error * More catch-up to fix lint errors introduced by merge. --------- Co-authored-by: Jim Su <jimsu@protonmail.com> Co-authored-by: Robert Brennan <accounts@rbren.io>
27 lines
1.5 KiB
Python
27 lines
1.5 KiB
Python
from opendevin import config
|
|
from opendevin.schema import ConfigType
|
|
from opendevin.action import fileop
|
|
from pathlib import Path
|
|
import pytest
|
|
|
|
|
|
|
|
def test_resolve_path():
|
|
assert fileop.resolve_path('test.txt', '/workspace') == Path(config.get(ConfigType.WORKSPACE_BASE)) / 'test.txt'
|
|
assert fileop.resolve_path('subdir/test.txt', '/workspace') == \
|
|
Path(config.get(ConfigType.WORKSPACE_BASE)) / 'subdir' / 'test.txt'
|
|
assert fileop.resolve_path(Path(fileop.SANDBOX_PATH_PREFIX) / 'test.txt', '/workspace') == \
|
|
Path(config.get(ConfigType.WORKSPACE_BASE)) / 'test.txt'
|
|
assert fileop.resolve_path(Path(fileop.SANDBOX_PATH_PREFIX) / 'subdir' / 'test.txt',
|
|
'/workspace') == Path(config.get(ConfigType.WORKSPACE_BASE)) / 'subdir' / 'test.txt'
|
|
assert fileop.resolve_path(Path(fileop.SANDBOX_PATH_PREFIX) / 'subdir' / '..' / 'test.txt',
|
|
'/workspace') == Path(config.get(ConfigType.WORKSPACE_BASE)) / 'test.txt'
|
|
with pytest.raises(PermissionError):
|
|
fileop.resolve_path(Path(fileop.SANDBOX_PATH_PREFIX) / '..' / 'test.txt', '/workspace')
|
|
with pytest.raises(PermissionError):
|
|
fileop.resolve_path(Path('..') / 'test.txt', '/workspace')
|
|
with pytest.raises(PermissionError):
|
|
fileop.resolve_path(Path('/') / 'test.txt', '/workspace')
|
|
assert fileop.resolve_path('test.txt', '/workspace/test') == \
|
|
Path(config.get(ConfigType.WORKSPACE_BASE)) / 'test' / 'test.txt'
|