跳到主要内容

openhands.core.config.utils

load_from_env

def load_from_env(cfg: AppConfig,
env_or_toml_dict: dict | MutableMapping[str, str])

Reads the env-style vars and sets config attributes based on env vars or a config.toml dict. Compatibility with vars like LLM_BASE_URL, AGENT_MEMORY_ENABLED, SANDBOX_TIMEOUT and others.

Arguments:

  • cfg - The AppConfig object to set attributes on.
  • env_or_toml_dict - The environment variables or a config.toml dict.

load_from_toml

def load_from_toml(cfg: AppConfig, toml_file: str = 'config.toml')

Load the config from the toml file. Supports both styles of config vars.

Arguments:

  • cfg - The AppConfig object to update attributes of.
  • toml_file - The path to the toml file. Defaults to 'config.toml'.

finalize_config

def finalize_config(cfg: AppConfig)

More tweaks to the config after it's been loaded.

get_llm_config_arg

def get_llm_config_arg(llm_config_arg: str,
toml_file: str = 'config.toml') -> LLMConfig | None

Get a group of llm settings from the config file.

A group in config.toml can look like this:

The user-defined group name, like "gpt-3.5-for-eval", is the argument to this function. The function will load the LLMConfig object with the settings of this group, from the config file, and set it as the LLMConfig object for the app.

Note that the group must be under "llm" group, or in other words, the group name must start with "llm.".

[llm.gpt-3.5-for-eval]
model = 'gpt-3.5-turbo'
api_key = '...'
temperature = 0.5
num_retries = 8
...

Arguments:

  • llm_config_arg - The group of llm settings to get from the config.toml file.
  • toml_file - Path to the configuration file to read from. Defaults to 'config.toml'.

Returns:

  • LLMConfig - The LLMConfig object with the settings from the config file.

get_parser

def get_parser() -> argparse.ArgumentParser

Get the parser for the command line arguments.

parse_arguments

def parse_arguments() -> argparse.Namespace

Parse the command line arguments.

load_app_config

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.

Arguments:

  • set_logging_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.