Skip to content
Roboto
Esc
↑↓navigate↵open⌘Jpreview
On this page

roboto.config

Module Contents

DEFAULT_ROBOTO_CONFIG_DIR

roboto.config.DEFAULT_ROBOTO_CONFIG_DIR#View Source

DEFAULT_ROBOTO_DIR

roboto.config.DEFAULT_ROBOTO_DIR#View Source

DEFAULT_ROBOTO_PROFILE_NAME

roboto.config.DEFAULT_ROBOTO_PROFILE_NAME = 'default'#View Source

ROBOTO_API_ENDPOINT

roboto.config.ROBOTO_API_ENDPOINT = 'https://api.roboto.ai'#View Source

RobotoConfig

class roboto.config.RobotoConfig(/, **data)#View Source

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

Attributes

RobotoConfig.api_key

api_key str #

RobotoConfig.cache_dir

cache_dir pathlib.Path | None = None #

RobotoConfig.default_http_timeout

default_http_timeout roboto.env.Timeout #

RobotoConfig.endpoint

endpoint str = 'https://api.roboto.ai' #

RobotoConfig.from_env()

classmethod from_env(profile_override=None, env=None)#View Source

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()

get_cache_dir()#View Source

Return type

pathlib.Path

Attributes

RobotoConfig.org_id

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.

RobotoConfigFileProfileV0

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

Bases: pydantic.BaseModel

V0 Roboto configuration file

Parameters

data Any

Attributes

RobotoConfigFileProfileV0.default_endpoint

default_endpoint str = 'https://api.roboto.ai' #

RobotoConfigFileProfileV0.to_config()

to_config()#View Source

Return type

Attributes

RobotoConfigFileProfileV0.token

token str #

RobotoConfigFileV1

class roboto.config.RobotoConfigFileV1(/, **data)#View Source

Bases: pydantic.BaseModel

V1 Roboto configuration file

Parameters

data Any

Attributes

RobotoConfigFileV1.default_profile

default_profile str | None = 'default' #

RobotoConfigFileV1.profiles

profiles dict[str, RobotoConfig] #

RobotoConfigFileV1.validate()

validate()#View Source

Attributes

RobotoConfigFileV1.version

version Literal['v1'] #

logger

roboto.config.logger#View Source

resolve_cache_dir()

roboto.config.resolve_cache_dir(env, ensure_exists)#View Source

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

ensure_exists bool

Return type

pathlib.Path

resolve_config_file()

roboto.config.resolve_config_file(env)#View Source

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

Return type

pathlib.Path

Was this page helpful?