SamplingMessageContentBlock extension type
One block of a SamplingMessage's content, sent to or received from an LLM.
Could be either TextContent, ImageContent, AudioContent, ToolUseContent or ToolResultContent.
Switch on the type before casting to the more specific types. The two
arms a tools/call result cannot carry have their own checks,
isToolUse and isToolResult. A TextContent, ImageContent or
AudioContent read as a Content keeps the checks declared there.
This does not implement Content. A plain tools/call result never
carries ToolUseContent or ToolResultContent. Keeping sampling content
on its own type stops the two from being swapped by accident.
Doing is checks does not work because these are just extension types,
they all have the same runtime type (Map<String, Object?>).
- on
- Implementers
Constructors
-
SamplingMessageContentBlock.fromMap(Map<
String, Object?> value) -
factory
Properties
- isToolResult → bool
-
Whether or not this is a ToolResultContent.
no setter
- isToolUse → bool
-
Whether or not this is a ToolUseContent.
no setter
- type → String
-
The type of content.
no setter
Constants
- audio → const AudioContent Function({Annotations? annotations, required String data, Meta? meta, required String mimeType})
- Alias for AudioContent.new.
- image → const ImageContent Function({Annotations? annotations, required String data, Meta? meta, required String mimeType})
- Alias for ImageContent.new.
- text → const TextContent Function({Annotations? annotations, Meta? meta, required String text})
- Alias for TextContent.new.
-
toolResult
→ const ToolResultContent Function({required List<
Content> content, bool? isError, Meta? meta, Map<String, Object?> ? structuredContent, required String toolUseId}) - Alias for ToolResultContent.new.
-
toolUse
→ const ToolUseContent Function({required String id, required Map<
String, Object?> input, Meta? meta, required String name}) - Alias for ToolUseContent.new.