Class BlobPart
java.lang.Object
uno.anahata.asi.agi.event.BasicPropertyChangeSource
uno.anahata.asi.agi.message.AbstractPart
uno.anahata.asi.agi.message.BlobPart
- All Implemented Interfaces:
PropertyChangeSource, Rebindable
- Direct Known Subclasses:
ModelBlobPart, UserBlobPart
An abstract base class for binary data parts, such as an image or a document.
It can be created from raw bytes or directly from a file path, in which case
it retains a reference to the source path for traceability.
- Author:
- anahata
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final @NonNull byte[]The raw binary data.private final @NonNull StringThe MIME type of the data (e.g., "image/png", "application/pdf").private PathThe original source path if this blob was created from a file.Fields inherited from class BasicPropertyChangeSource
propertyChangeSupportModifier and TypeFieldDescriptionprotected PropertyChangeSupportSupport for firing property change events. -
Constructor Summary
ConstructorsModifierConstructorDescriptionBlobPart(@NonNull AbstractMessage message, @NonNull String mimeType, @NonNull byte[] data) Constructs a BlobPart from raw byte data and a specified MIME type.protectedBlobPart(@NonNull AbstractMessage message, @NonNull String mimeType, @NonNull byte[] data, @NonNull Path sourcePath) Internal constructor for BlobParts with a source path. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidHook for subclasses to inject specialized metadata into the part header.asText()Returns the content of the part as a simple string.protected voidPerforms the lazy, model-specific token calculation for this part.protected intTemplate method hook for subclasses to provide their specific default max depth policy.Returns a summarized string representation of the part's content to be used as a "Hint" when the part is effectively pruned.Methods inherited from class AbstractPart
createMetadataHeader, getAgi, getAgiConfig, getEffectiveMaxDepth, getEffectiveTokenCount, getIdentityLabel, getMetadataTokenCount, getRemainingDepth, getTokenCount, isAuto, isEffectivelyPruned, isPinned, isPruned, remove, resetTokenCount, setExpanded, setPruningState, setPruningState, setTokenCountModifier and TypeMethodDescriptionCreates a standardized text header containing metadata for this part.getAgi()Gets the parent agi session.Gets the agi configuration.final intThe definitive method for resolving the max depth policy for this part.intCalculates the total "effective" tokens contributed by this part.protected StringReturns the identity label for the metadata header (e.g., "Part ID: 45").intCalculates the token count of the metadata header for this part.intCalculates the remaining depth before this part is auto-pruned.intRetrieves the cached token count for this part.booleanisAuto()Checks if this part is managed automatically.booleanCalculates the EFFECTIVE pruned state of this part.booleanisPinned()Checks if this part is explicitly pinned.booleanisPruned()Checks if this part is explicitly pruned.voidremove()Removes this part from its parent message and severs the bidirectional link.voidResets the cached token count, forcing a lazy, background recalculation on the next call to getTokenCount().voidsetExpanded(boolean expanded) Sets the expanded state and fires a property change event.voidsetPruningState(PruningState pruningState) Sets the pruning state of this part and fires a property change event.voidsetPruningState(PruningState pruningState, String reason) Sets the pruning state of this part with an optional reason.voidsetTokenCount(int tokenCount) Sets the token count and fires a property change event.Methods inherited from class BasicPropertyChangeSource
addPropertyChangeListener, addPropertyChangeListener, rebind, removePropertyChangeListener, removePropertyChangeListenerModifier and TypeMethodDescriptionvoidAdds a property change listener.voidaddPropertyChangeListener(String propertyName, PropertyChangeListener listener) Adds a property change listener for a specific property.voidrebind()Re-initializes the transientPropertyChangeSupportafter deserialization.voidRemoves a property change listener.voidremovePropertyChangeListener(String propertyName, PropertyChangeListener listener) Removes a property change listener for a specific property.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface PropertyChangeSource
getPropertyChangeSupportModifier and TypeMethodDescriptionGets the PropertyChangeSupport instance for this object.
-
Field Details
-
mimeType
The MIME type of the data (e.g., "image/png", "application/pdf"). -
data
@NonNull private final @NonNull byte[] dataThe raw binary data. -
sourcePath
The original source path if this blob was created from a file. Can be null.
-
-
Constructor Details
-
BlobPart
public BlobPart(@NonNull @NonNull AbstractMessage message, @NonNull @NonNull String mimeType, @NonNull @NonNull byte[] data) Constructs a BlobPart from raw byte data and a specified MIME type.- Parameters:
message- The message this part belongs to.mimeType- The MIME type.data- The binary data.
-
BlobPart
protected BlobPart(@NonNull @NonNull AbstractMessage message, @NonNull @NonNull String mimeType, @NonNull @NonNull byte[] data, @NonNull @NonNull Path sourcePath) Internal constructor for BlobParts with a source path.- Parameters:
message- The parent message.mimeType- The MIME type.data- The binary data.sourcePath- The source file path.
-
-
Method Details
-
asText
Description copied from class:AbstractPartReturns the content of the part as a simple string. This is implemented by subclasses.- Specified by:
asTextin classAbstractPart- Returns:
- The text representation of the part.
-
getPrunedHint
Returns a summarized string representation of the part's content to be used as a "Hint" when the part is effectively pruned. Defaults to a formatted version ofAbstractPart.asText(). Provides essential binary metadata (MIME and Size) when the content is pruned.- Overrides:
getPrunedHintin classAbstractPart- Returns:
- The pruned hint string.
-
calculateTokenCount
protected void calculateTokenCount()Performs the lazy, model-specific token calculation for this part. This is implemented by subclasses to perform the actual calculation.Calculates the multimodal token count for this binary part using the active model.
- Specified by:
calculateTokenCountin classAbstractPart
-
appendMetadata
Hook for subclasses to inject specialized metadata into the part header. Always includes the source path in the metadata header if available, ensuring semantic continuity even when pruned.- Overrides:
appendMetadatain classAbstractPart- Parameters:
sb- The StringBuilder building the header.
-
getDefaultMaxDepth
protected int getDefaultMaxDepth()Description copied from class:AbstractPartTemplate method hook for subclasses to provide their specific default max depth policy. This is the fallback value used when no explicitmaxDepthis set on the instance.- Specified by:
getDefaultMaxDepthin classAbstractPart- Returns:
- The default maximum depth for this part type.
-

