Class TextPart
java.lang.Object
uno.anahata.asi.agi.event.BasicPropertyChangeSource
uno.anahata.asi.agi.message.AbstractPart
uno.anahata.asi.agi.message.TextPart
- All Implemented Interfaces:
PropertyChangeSource, Rebindable
- Direct Known Subclasses:
ModelTextPart, UserTextPart
An abstract base class for text-based message parts.
It supports reactive UI updates by firing property change events when the text is modified.
- Author:
- anahata-gemini-pro-2.5
-
Field Summary
FieldsFields inherited from class BasicPropertyChangeSource
propertyChangeSupport -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidHook for subclasses to inject specialized metadata into the part header.voidappendText(String delta) Appends text to the existing content and fires a property change event.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.booleanIndicates if this text part represents a model thought process.voidResets the cached token count, forcing a lazy, background recalculation on the next call to getTokenCount().voidSets the text content and fires a property change event for the "text" property.Methods inherited from class AbstractPart
createMetadataHeader, getAgi, getAgiConfig, getEffectiveMaxDepth, getEffectiveTokenCount, getIdentityLabel, getMetadataTokenCount, getPrunedHint, getRemainingDepth, getTokenCount, isAuto, isEffectivelyPruned, isPinned, isPruned, remove, setExpanded, setPruningState, setPruningState, setTokenCountMethods inherited from class BasicPropertyChangeSource
addPropertyChangeListener, addPropertyChangeListener, rebind, removePropertyChangeListener, removePropertyChangeListenerMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface PropertyChangeSource
getPropertyChangeSupport
-
Field Details
-
text
The text content of this part.
-
-
Constructor Details
-
TextPart
Constructs a new TextPart.- Parameters:
message- The parent message.text- The initial text content.
-
-
Method Details
-
setText
Sets the text content and fires a property change event for the "text" property. Also updates the token count using the active session tokenizer.- Parameters:
text- The new text content to apply.
-
appendText
Appends text to the existing content and fires a property change event. Also updates the token count using the active session tokenizer.- Parameters:
delta- The text to append.
-
calculateTokenCount
protected void calculateTokenCount()Performs the lazy, model-specific token calculation for this part. This is implemented by subclasses to perform the actual calculation.Re-calculates the text token count using the currently selected model.
- Specified by:
calculateTokenCountin classAbstractPart
-
resetTokenCount
public void resetTokenCount()Resets the cached token count, forcing a lazy, background recalculation on the next call to getTokenCount().- Overrides:
resetTokenCountin classAbstractPart
-
asText
Returns 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.
-
getDefaultMaxDepth
protected int getDefaultMaxDepth()Template 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. Returns the default maximum depth to keep a text part in context, as defined in the agi configuration.- Specified by:
getDefaultMaxDepthin classAbstractPart- Returns:
- The default maximum depth for this part type.
-
appendMetadata
Description copied from class:AbstractPartHook for subclasses to inject specialized metadata into the part header.- Overrides:
appendMetadatain classAbstractPart- Parameters:
sb- The StringBuilder building the header.
-
isThought
public boolean isThought()Indicates if this text part represents a model thought process. For a generic TextPart, this is always false.- Returns:
- always false
-

