Before diving into this content, it would be helpful to read the following guides:
The following features are available in the following SDK versions:
- Python SDK: >=0.1.141
- JS/TS SDK: >=0.2.5
Attachment
type in Python and Uint8Array
/ ArrayBuffer
in TypeScript.
- Python
- TypeScript
In the Python SDK, you can use the
Attachment
type to add files to your traces. Each Attachment
requires:mime_type
(str): The MIME type of the file (e.g.,"image/png"
).data
(bytes | Path): The binary content of the file, or the file path.
(mime_type, data)
for convenience.Simply decorate a function with @traceable
and include your Attachment
instances as arguments. Note that to use the file path instead of the raw bytes, you need to set the dangerously_allow_filesystem
flag to True
in your traceable decorator.