roboto.config#
Module Contents#
- roboto.config.DEFAULT_ROBOTO_CONFIG_DIR#
- roboto.config.DEFAULT_ROBOTO_DIR#
- roboto.config.DEFAULT_ROBOTO_PROFILE_NAME = 'default'#
- roboto.config.ROBOTO_API_ENDPOINT = 'https://api.roboto.ai'#
- class roboto.config.RobotoConfig(/, **data)#
Bases:
pydantic.BaseModelRobotoConfig captures an
api_keyandendpointrequired to programmatically interact with Roboto. Multiple profiles can be configured if desired.- Parameters:
data (Any)
- api_key: str#
- cache_dir: pathlib.Path | None = None#
- default_http_timeout: roboto.env.Timeout#
- endpoint: str = 'https://api.roboto.ai'#
- classmethod from_env(profile_override=None, env=None)#
Build a config from the access token in the environment, or else from a profile in the Roboto config file.
A token in
ROBOTO_API_KEYorROBOTO_BEARER_TOKENtakes precedence, and is sent to the endpoint inROBOTO_SERVICE_ENDPOINT, or tohttps://api.roboto.aiwhen that is unset. Without a token, the config comes from the file atROBOTO_CONFIG_FILE, or~/.roboto/config.jsonwhen that is unset. Either way,ROBOTO_CACHE_DIRandROBOTO_DEFAULT_HTTP_TIMEOUT, when set, override the profile’scache_diranddefault_http_timeout.- Parameters:
profile_override (Optional[str]) – Config file profile to read, ahead of
ROBOTO_PROFILEand the file’s default profile.env (Optional[roboto.env.RobotoEnv]) – Roboto environment variables to read. Defaults to the process’s own, through
RobotoEnv.default().
- Raises:
FileNotFoundError – No access token is set and the config file doesn’t exist.
OSError – The config file exists but can’t be read.
ValueError – The config file isn’t a JSON object, or has no usable profile by the chosen name.
- Return type:
- get_cache_dir()#
- Return type:
pathlib.Path
- org_id: str | None = None#
Organization to act in when the caller names none and
ROBOTO_ORG_IDis unset. The CLI andfrom_env()read it. Only a member of several organizations needs it.roboto setupsaves it to the config file profile; a config built fromROBOTO_API_KEYorROBOTO_BEARER_TOKENhas none.
- class roboto.config.RobotoConfigFileProfileV0(/, **data)#
Bases:
pydantic.BaseModelV0 Roboto configuration file
- Parameters:
data (Any)
- default_endpoint: str = 'https://api.roboto.ai'#
- to_config()#
- Return type:
- token: str#
- class roboto.config.RobotoConfigFileV1(/, **data)#
Bases:
pydantic.BaseModelV1 Roboto configuration file
- Parameters:
data (Any)
- default_profile: str | None = 'default'#
- profiles: dict[str, RobotoConfig]#
- validate()#
- version: Literal['v1']#
- roboto.config.logger#
- roboto.config.resolve_cache_dir(env, ensure_exists)#
Resolve the base directory under which the SDK caches files it fetches from Roboto.
Prefers
ROBOTO_CACHE_DIRfromenv; absent that, the platform-conventional per-user cache directory.ensure_existsapplies only to the platform default: when true, resolving it also creates the directory on disk. A directory supplied throughROBOTO_CACHE_DIRis returned as-is and never created here.- Parameters:
env (roboto.env.RobotoEnv)
ensure_exists (bool)
- Return type:
pathlib.Path
- roboto.config.resolve_config_file(env)#
Resolve the path of the Roboto config file:
ROBOTO_CONFIG_FILEfromenv, else~/.roboto/config.json.The file at the returned path may not exist.
- Parameters:
env (roboto.env.RobotoEnv)
- Return type:
pathlib.Path