ImageReference
A reference to an image in a session’s transcript.
Declaration
struct ImageReferenceMentioned in
Overview
Use ImageReference to allow the model to reference images from the current LanguageModelSession’s transcript.
You can define an ImageReference as an argument to a Tool. Retrieve the referenced image from the transcript during the tool call.
struct MyTool: Tool {
@SessionProperty(\.history) var history
@Generable
struct Arguments {
var image: ImageReference
}
public func call(arguments: Arguments) async throws -> Output {
guard let imageAttachment = arguments.image.resolve(in: history) else {
throw ImageToolError.imageNotFound(arguments.image.attachmentLabel)
}
let image = imageAttachment.cgImage
...
}
}