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.BaseModel

RobotoConfig captures an api_key and endpoint required 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_KEY or ROBOTO_BEARER_TOKEN takes precedence, and is sent to the endpoint in ROBOTO_SERVICE_ENDPOINT, or to https://api.roboto.ai when that is unset. Without a token, the config comes from the file at ROBOTO_CONFIG_FILE, or ~/.roboto/config.json when that is unset. Either way, ROBOTO_CACHE_DIR and ROBOTO_DEFAULT_HTTP_TIMEOUT, when set, override the profile’s cache_dir and default_http_timeout.

Parameters:
  • profile_override (Optional[str]) – Config file profile to read, ahead of ROBOTO_PROFILE and 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:

RobotoConfig

get_cache_dir()#
Return type:

pathlib.Path

org_id: str | None = None#

Organization to act in when the caller names none and ROBOTO_ORG_ID is unset. The CLI and from_env() read it. Only a member of several organizations needs it. roboto setup saves it to the config file profile; a config built from ROBOTO_API_KEY or ROBOTO_BEARER_TOKEN has none.

class roboto.config.RobotoConfigFileProfileV0(/, **data)#

Bases: pydantic.BaseModel

V0 Roboto configuration file

Parameters:

data (Any)

default_endpoint: str = 'https://api.roboto.ai'#
to_config()#
Return type:

RobotoConfig

token: str#
class roboto.config.RobotoConfigFileV1(/, **data)#

Bases: pydantic.BaseModel

V1 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_DIR from env; absent that, the platform-conventional per-user cache directory. ensure_exists applies only to the platform default: when true, resolving it also creates the directory on disk. A directory supplied through ROBOTO_CACHE_DIR is returned as-is and never created here.

Parameters:
Return type:

pathlib.Path

roboto.config.resolve_config_file(env)#

Resolve the path of the Roboto config file: ROBOTO_CONFIG_FILE from env, else ~/.roboto/config.json.

The file at the returned path may not exist.

Parameters:

env (roboto.env.RobotoEnv)

Return type:

pathlib.Path