ADK.Artifact.Store behaviour (ADK v0.0.1-alpha.1)

Copy Markdown View Source

Behaviour for pluggable artifact storage backends.

Mirrors Python ADK's BaseArtifactService. Artifacts are binary blobs (files, images, etc.) attached to a session, keyed by filename with versioning support.

Summary

Callbacks

List artifact filenames for a session.

Load an artifact by filename and optional version.

Save an artifact, returning the new version number.

Types

artifact()

@type artifact() :: %{data: binary(), content_type: String.t(), metadata: map()}

Callbacks

delete(app_name, user_id, session_id, filename, opts)

@callback delete(
  app_name :: String.t(),
  user_id :: String.t(),
  session_id :: String.t(),
  filename :: String.t(),
  opts :: keyword()
) :: :ok | {:error, term()}

Delete an artifact by filename.

list(app_name, user_id, session_id, opts)

@callback list(
  app_name :: String.t(),
  user_id :: String.t(),
  session_id :: String.t(),
  opts :: keyword()
) :: {:ok, [String.t()]} | {:error, term()}

List artifact filenames for a session.

load(app_name, user_id, session_id, filename, opts)

@callback load(
  app_name :: String.t(),
  user_id :: String.t(),
  session_id :: String.t(),
  filename :: String.t(),
  opts :: keyword()
) :: {:ok, artifact()} | :not_found | {:error, term()}

Load an artifact by filename and optional version.

save(app_name, user_id, session_id, filename, artifact, opts)

@callback save(
  app_name :: String.t(),
  user_id :: String.t(),
  session_id :: String.t(),
  filename :: String.t(),
  artifact :: artifact(),
  opts :: keyword()
) :: {:ok, non_neg_integer()} | {:error, term()}

Save an artifact, returning the new version number.