JavaScript Client v7.5.0: Describe images with Agent Action Transform

Image descriptions

Transform can now describe images by targeting a string, text or Portable Text field (array with block)
with operation: {type: 'image-description'}.

Custom instructions for image description targets will be used to generate the description.

Targeting image fields

If a target is a descendant field of an image object, no sourcePath is required in the operation:

For example:

target: {path: ['image', 'description'], operation: {type: 'image-description'} }

target: {path: ['array', {_key: 'abc'}, 'alt'], operation: {type: 'image-description'} } //assuming the item in the array on the key-ed path is an image

target: {path: ['image'], include: ['portableTextField'], operation: {type: 'image-description'}, instruction: 'Use formatting and headings to describe the image in great detail' }

Targeting non-image fields

If the target image description lives outside an image object, use the sourcePath option to specify the path to the image field.
sourcePath must be an image or image asset field.

For example:

target: {path: ['description'], operation: {type: 'image-description', sourcePath: ['image', 'asset'] }

target: {path: ['wrapper', 'title'], operation: {type: 'image-description', sourcePath: ['array', {_key: 'abc'}, 'image'] }

target: {path: ['wrapper'], include: ['portableTextField'], operation: {type: 'image-description', sourcePath: ['image', 'asset'] }, instruction: 'Use formatting and headings to describe the image in great detail' }

Learn more about using target with transform in the Targets and paths guide.