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
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
|
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', ...}