ImageTokenizer class
Handles proper image tokenization for multimodal AI models to prevent "Prompt contained 0 image tokens but received 1 images" errors and corruption that causes repeating text patterns.
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
createFallbackPrompt(
String text, {String? errorMessage}) → String - Creates a safe fallback prompt when image processing fails
-
createImageMessage(
{required String text, required ProcessedImage processedImage, required String role}) → Map< String, dynamic> - Creates a properly structured message object for multimodal AI models that prevents tokenization errors and image corruption.
-
createImagePrompt(
{required String text, required ProcessedImage processedImage, required ModelType modelType}) → String - Creates a properly formatted prompt for models that expect specific image token patterns.
-
detectCorruptionPatterns(
String response) → bool - Detects potential image corruption patterns in model responses
-
validateImageTokens(
String prompt, int expectedImageCount) → bool - Validates that a message contains proper image tokens