Glossary of Chains concepts and terminology
run_remote()
for other Chainlets to call.run_remote()
method is
required — and we can layer in other concepts to create a more capable Chainlet.
remote_config
class variable
within the Chainlet:
__init__()
, which is run exactly once when the Chainlet is
deployed or scaled up.
DeploymentContext
object as an optional argument to the __init__
-method of a Chainlet.
This allows you to use secrets within your Chainlet, such as using
a hf_access_token
to access a gated model on Hugging Face (note that when
using secrets, they also need to be added to the assets
).
chains.depends()
function in
Chainlets’ __init__()
method to track the dependency relationship between
different Chainlets within a Chain.
This syntax, inspired by dependency injection, is used to translate local Python
function calls into calls to the remote Chainlets in production.
Once a dependency Chainlet is added with
chains.depends()
, its
run_remote()
method can
call this dependency Chainlet, e.g. below HelloAll
we can make calls to
SayHello
:
run_remote()
method is run each time the Chainlet is called. It is the
sole public interface for the Chainlet (though you can have as many private
helper functions as you want) and its inputs and outputs must have type
annotations.
In run_remote()
you implement the actual work of the Chainlet, such as model
inference or data chunking:
async
method and using async APIs for
doing all the work (e.g. downloads, vLLM or TRT inference).
It is possible to stream results back, see our
streaming guide.
run_remote()
makes calls to other Chainlets, e.g. invoking a dependency
Chainlet for each element in a list, you can benefit from concurrent
execution, by making the run_remote()
an async
method and starting the
calls as concurrent tasks
asyncio.ensure_future(self._dep_chainlet.run_remote(...))
.@chains.mark_entrypoint
decorator, one Chainlet within a file is set as the entrypoint to the chain.
pydantic
data typesint
, float
,
or list[str]
.Tips for Truss users
truss init
and creating a Truss in a directory, a Chain
is a single file, giving you more flexibility for implementing multi-step
model inference. Create an example with truss chains init
.config.yaml
file.Chainlet != TrussModel
.