Class Base64Attachment

java.lang.Object
dev.braintrust.trace.Base64Attachment

public class Base64Attachment extends Object
Utility to serialize LLM attachment data in a braintrust-friendly manner.

Users of the SDK likely don't need to use this utility directly because instrumentation will properly serialize messages out of the box.

The serialized json will conform to the otel input/output GenericPart schema. See https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-input-messages.json and https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-output-messages.json

  • Method Details

    • of

      public static Base64Attachment of(String base64DataUri)
      Create a new attachment out of base64 data
      Parameters:
      base64DataUri - must conform to data:(content-type);base64,BYTES
    • ofFile

      public static Base64Attachment ofFile(Base64Attachment.ContentType contentType, String filePath)
      convenience utility to convert a file to a base64 attachment
    • createSerializer

      public static com.fasterxml.jackson.databind.JsonSerializer<Base64Attachment> createSerializer()
      create a jackson serializer for attachment data
    • getType

      public String getType()
    • getBase64Data

      public String getBase64Data()