unaiverse.streams¶
Agents exchange data as samples on streams. A stream carries one input or one output of a processor, the data of a sensor, the samples of a dataset or the messages of a chat. This package defines how a stream is described, how it holds its samples and how the actions of an agent reach it. It has four layers, one per module. The narrative guide is Data streams.
| Module | Layer |
|---|---|
dataprops |
Description. StreamType is what a developer writes in proc_inputs and proc_outputs. It builds the DataProps that describe the data of one stream: type (tensor, img, text, file or all), tensor shape, dtype, labels, transforms to and from the processor, pace (delta), broadcast (pubsub) and network (public). FileContainer is the sample of a file stream. |
streams |
Storage. A Stream holds the last sample of each interaction for one DataProps. A BufferedStream records its samples and replays them one per clock cycle. Dataset, ImageFileStream, LabelStream, StringStream and TokensStream are read-only buffered streams filled from data on disk or in memory. |
streamlib |
Generators. Buffered streams that compute synthetic signals (random values, sine and square waves, sums of sines) and their presets. |
streamproxy |
Access. A StreamProxy binds a group of streams to an interaction uuid. The agent reads and writes its processor streams through four of them: stdin, stdtar, stdext and stdout. |
The path of one sample through these layers is the following:
- The agent turns each
StreamTypeof its processor into oneStreamper network and names it (proc_input_0,proc_output_0, ...). - A sample that arrives from another peer is stored with
Stream.setunder the uuid of the interaction that carries it. - When the behavior runs
process, the interaction manager bindsstdinandstdoutto the streams and the uuid of the interaction.stdin.get()returns one sample per input andDataProps.check_and_preprocesschecks it and converts it into a tensor. - The processor runs.
DataProps.check_and_postprocesschecks each output and converts it back.stdout.set(...)stores the outputs and the node sends them to the peer that made the request.
unaiverse.streams imports its three modules streams, dataprops and streamproxy and re-exports the following names. Each name is documented on the page of the module that defines it.
| Name | Defined in |
|---|---|
StreamType, DataProps |
unaiverse.streams.dataprops |
Stream, BufferedStream, Dataset, ImageFileStream, LabelStream, StringStream, TokensStream, serialize_payload, deserialize_payload |
unaiverse.streams.streams |
TensorLabels, FileContainer, Data, StreamProxy and the generators of streamlib are not re-exported. Import them from their modules:
from unaiverse.streams import StreamType, Stream
from unaiverse.streams.dataprops import FileContainer
from unaiverse.streams.streamlib import Sin
from unaiverse.streams.streamproxy import StreamProxy
Text streams also carry interactive messages: forms, pictures and charts written as fenced blocks inside a string (see unaiverse.uai and Interactive messages).