Configuration¶
A node takes most of its settings from its constructor and from run() (Serve a model as a lone wolf, Build a world). The rest comes from environment variables that the SDK reads once when unaiverse is imported. The class unaiverse.custom.Custom collects the defaults of the SDK in one place. The variables must be in the environment before the script starts:
Environment variables¶
Account¶
| Variable | Default | Effect |
|---|---|---|
NODE_KEY |
not set | the account key, used when the constructor of Node receives none (Installation) |
NODE_IGNORE_ALIVE |
0 |
1 lets a node start even when UNaIVERSE reports that the same node is already running |
Logging¶
| Variable | Default | Effect |
|---|---|---|
NODE_PRINT |
0 |
1 records every channel of the logger, 0 only the three that are always on |
NODE_LOG_CHANNELS |
empty | comma-separated channels to record besides the three always on (for example NETWORK,SESSION), in place of what NODE_PRINT selects |
NODE_SCREEN_BASIC_PRINT |
0 |
1 prints on screen only the three channels that are always on and keeps recording the others |
NODE_LOG |
0 |
1 also writes every recorded line to a JSON Lines file |
NODE_LOG_APPEND |
0 |
1 keeps that file across restarts instead of overwriting it |
NODE_LOG_SINK_MODULE |
empty | the import path of a module whose function attach(log) the node calls at startup so that the module can observe the log |
NODE_LIBP2PLOG |
0 |
1 also records the raw output of the native networking library, on the channel P2P |
Network¶
| Variable | Default | Effect |
|---|---|---|
NODE_STARTING_PORT |
0 |
the first port P of eight: P to P+3 for the public network and P+4 to P+7 for the network of the world (0 picks free ports at random) |
NODE_IS_PUBLIC |
0 |
1 tells the node that its addresses are reachable from the internet |
NODE_IS_PUBLIC_RELAY |
0 |
1 makes the node offer a relay service in the public network to peers that cannot be reached directly |
NODE_IS_ISOLATED |
0 |
1 accepts connections only from friendly peers |
NODE_USE_TLS |
0 |
1 enables TLS on the transports that support it |
DOMAIN |
not set | the domain name of the node, with TLS |
TLS_CERT_PATH, TLS_KEY_PATH |
not set | the certificate and the private key, with TLS |
NODE_SAVE_RUNNING_ADDRESSES |
not set | an existing folder where the node appends its public addresses to running.csv when it starts |
Regardless of NODE_IS_PUBLIC_RELAY, a world node always offers a relay to its members in the network of the world.
Processors¶
| Variable | Default | Effect |
|---|---|---|
NODE_OFFLOAD |
1 |
1 runs a ModuleWrapper processor in a worker thread during process and learn in order to keep the node answering its peers during a long forward or backward pass (0 runs it inline) |
NODE_OFFLOAD_SLOW |
0.5 |
in an interaction with several steps the processor runs inline, one sample per step, unless its last call took at least this many seconds |
PROC_DEVICE |
not set | the device of the ready-made processors when their device argument is None (for example cuda:0), with the CPU as fallback |
FEATHERLESS_API_KEY |
not set | the key of FeatherlessAPI when its api_key argument is None |
FEATHERLESS_KEY_UNITS |
8 |
the units of that key when key_units is None |
MODEL_ID |
not set | the Featherless model when a call gives none |
OPENROUTER_API_KEY |
not set | the key of OpenRouterAPI when its api_key argument is None |
OPENROUTER_MODEL_ID |
not set | the model of OpenRouterAPI when its model argument is None |
GW_HOST, GW_PORT |
127.0.0.1, 11321 |
where the local gateway shared by the FeatherlessAPI processors of one machine listens |
GW_UNITS |
8 |
the units of a key that declares none |
GW_VALID_COSTS |
1,2,4 |
the costs that a call may declare |
GW_LOCKFILE |
a file in the temporary folder | the lock that lets only one process start the gateway |
GW_GRACE |
10 |
seconds after which the gateway stops when no process has registered with it |
The Custom class¶
Custom holds the defaults of the SDK as class attributes. A script can change one before it builds its node, for example to allow larger messages or to keep received files elsewhere:
from unaiverse.custom import Custom
Custom.MAX_FILE_SIZE = 200 * 1024 * 1024
Custom.DOWNLOADS_DIR = "/data/unaiverse-downloads"
The attributes that a script changes most often are:
| Attribute | Default | Meaning |
|---|---|---|
DEFAULT_INTER_TIMEOUT |
300. |
seconds after which an interaction without an answer completes with TIMEOUT |
MAX_INTERACTIONS |
100 |
interactions that an agent keeps open at the same time |
REJOINING_WAIT |
30. |
seconds before an agent asks again to join a world it was disconnected from |
SLOW_DOWN_CLOCK_AFTER, SLOW_CLOCK_DELTA |
10., 2. |
after this many seconds without exchanges or interactions, the node ticks every SLOW_CLOCK_DELTA seconds |
SEND_QUEUE_MAX_MSGS_PER_PEER |
64 |
messages waiting to be written to one peer (a full queue refuses new messages until it drains to half) |
MAX_MESSAGE_SIZE |
1 GB | the largest message that a node sends or receives (messages above CHUNK_SIZE, 5 MB, travel in chunks) |
LEGACY_MAX_MESSAGE_SIZE |
50 MB | the limit towards peers that do not support chunked messages, such as older nodes and browsers |
ACCEPT_FILES |
True |
whether the node accepts files from its peers |
MAX_FILE_SIZE |
0 |
the largest file sent or received (0 means no limit) |
DOWNLOADS_DIR |
None |
where received files go (None means Downloads in the folder of the key, ~/.unaiverse/Downloads on Linux and macOS) |
The other attributes tune the network loop, the send queues, the reassembly of large messages and the names that the behaviors reserve. Their comments in unaiverse/custom.py explain each one.
Logging¶
The node, the agent and the role code log through the same object unaiverse.utils.logger.log. Each line goes to one channel:
| Channel | What it carries |
|---|---|
CRITICAL |
fatal conditions (always on) |
ERROR |
errors and warnings that do not stop the node (always on) |
USER |
the output meant for whoever runs the node, such as log.user(...) in role code (always on) |
NETWORK |
connections, disconnections and the routing of messages |
SESSION |
the life of each session: dialing, handshake, keep-alive, reconnection and close |
CPOOL |
the connection pool: slots, evictions and limits |
INTER |
interactions between nodes |
STREAMS |
the flow of stream data |
STATEM |
a snapshot of the state of the node at every tick |
MISC |
everything else |
DEBUG |
fine-grained diagnostics |
P2P |
the raw output of the native networking library, with NODE_LIBP2PLOG=1 |
The three channels that are always on are recorded and printed in every configuration. The others are recorded with NODE_PRINT=1 or when NODE_LOG_CHANNELS names them. NODE_SCREEN_BASIC_PRINT=1 keeps them off the screen. Every record also carries a tag that says whether it concerns the public network (pub), the network of the world (prv) or neither (gen).
With NODE_LOG=1 the node writes its records as JSON Lines to <script>.jsonl in the folder of the script that started it. Role code writes on the same channels:
from unaiverse.utils.logger import log
log.user("Lecture 2 of 3")
log.error("No data folder configured")
log.debug("Next sample", sub="prv")
log.critical(...) records the message and raises an exception that stops the caller.