mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
Co-authored-by: Rehan Ganapathy <rehanganapathy@MACASF.local>
This commit is contained in:
parent
dd228c07e0
commit
c8a933590a
@ -91,7 +91,7 @@ async def main():
|
||||
return
|
||||
|
||||
logger.setLevel(logging.WARNING)
|
||||
config = load_app_config()
|
||||
config = load_app_config(config_file=args.config_file)
|
||||
sid = 'cli'
|
||||
|
||||
agent_cls: Type[Agent] = Agent.get_cls(config.default_agent)
|
||||
|
||||
@ -281,6 +281,12 @@ def get_llm_config_arg(
|
||||
def get_parser() -> argparse.ArgumentParser:
|
||||
"""Get the parser for the command line arguments."""
|
||||
parser = argparse.ArgumentParser(description='Run an agent with a specific task')
|
||||
parser.add_argument(
|
||||
'--config-file',
|
||||
type=str,
|
||||
default='config.toml',
|
||||
help='Path to the config file (default: config.toml in the current directory)',
|
||||
)
|
||||
parser.add_argument(
|
||||
'-d',
|
||||
'--directory',
|
||||
@ -375,14 +381,17 @@ def parse_arguments() -> argparse.Namespace:
|
||||
return parsed_args
|
||||
|
||||
|
||||
def load_app_config(set_logging_levels: bool = True) -> AppConfig:
|
||||
"""Load the configuration from the config.toml file and environment variables.
|
||||
def load_app_config(
|
||||
set_logging_levels: bool = True, config_file: str = 'config.toml'
|
||||
) -> AppConfig:
|
||||
"""Load the configuration from the specified config file and environment variables.
|
||||
|
||||
Args:
|
||||
set_logger_levels: Whether to set the global variables for logging levels.
|
||||
config_file: Path to the config file. Defaults to 'config.toml' in the current directory.
|
||||
"""
|
||||
config = AppConfig()
|
||||
load_from_toml(config)
|
||||
load_from_toml(config, config_file)
|
||||
load_from_env(config, os.environ)
|
||||
finalize_config(config)
|
||||
if set_logging_levels:
|
||||
|
||||
@ -228,7 +228,7 @@ if __name__ == '__main__':
|
||||
# Load the app config
|
||||
# this will load config from config.toml in the current directory
|
||||
# as well as from the environment variables
|
||||
config = load_app_config()
|
||||
config = load_app_config(config_file=args.config_file)
|
||||
|
||||
# Override default LLM configs ([llm] section in config.toml)
|
||||
if args.llm_config:
|
||||
|
||||
@ -123,10 +123,11 @@ def test_help_message(capsys):
|
||||
'--eval-ids EVAL_IDS',
|
||||
'-l LLM_CONFIG, --llm-config LLM_CONFIG',
|
||||
'-n NAME, --name NAME',
|
||||
'--config-file CONFIG_FILE',
|
||||
]
|
||||
|
||||
for element in expected_elements:
|
||||
assert element in help_output, f"Expected '{element}' to be in the help message"
|
||||
|
||||
option_count = help_output.count(' -')
|
||||
assert option_count == 14, f'Expected 14 options, found {option_count}'
|
||||
assert option_count == 15, f'Expected 15 options, found {option_count}'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user