Configs
lazyllm.Config
Bases: object
Config is a configuration class provided by LazyLLM, which loads configurations of LazyLLM framework from config files, environment variables, or specify them explicitly. it can export all configuration items as well. The Config module automatically generates an object named 'config' containing all configurations.
Source code in lazyllm/configs.py
done()
Check if any configuration items in the config.json file that is not loaded by the add method.
Source code in lazyllm/configs.py
getenv(name, type, default=None)
Get value of LazyLLM-related environment variables.
Parameters:
-
name(str) –The name of the environment variable (without the prefix), case-insensitive. The function obtains value
-
type(type) –Specifies the type of the configuration, for example, str. For boolean types, the function will
-
default(optional, default:None) –If the value of the environment variable cannot be obtained, this value is returned.
Source code in lazyllm/configs.py
add(name, type, default=None, env=None)
Loads value into LazyLLM configuration item. The function first attempts to find the value with the given name from the dict loaded from config.json. If found, it removes the key from the dict and saves the value to the config. If 'env' is a string, the function calls getenv to look for the corresponding LazyLLM environment variable, and if it's found, writes it to the config. If 'env' is a dictionary, the function attempts to call getenv to find the environment variables corresponding to the keys in the dict and convert them to boolean type. If the converted boolean value is True, the value corresponding to the current key in the dict is written to the config.
Parameters:
-
name(str) –The name of the configuration item
-
type(type) –The type of the configuration
-
default(optional, default:None) –The default value of the configuration if no value can be obtained
-
env(optional, default:None) –The name of the environment variable without the prefix, or a dictionary where the keys are the
Source code in lazyllm/configs.py
get_all_configs()
Get all configurations from the config.
Examples:
>>> import lazyllm
>>> from lazyllm.configs import config
>>> config['launcher']
'empty'
>>> config.get_all_configs()
{'home': '~/.lazyllm/', 'mode': <Mode.Normal: (1,)>, 'repr_ml': False, 'rag_store': 'None', 'redis_url': 'None', ...}