Class GeminiModelMessage
java.lang.Object
uno.anahata.asi.agi.event.BasicPropertyChangeSource
uno.anahata.asi.agi.message.AbstractMessage
uno.anahata.asi.agi.message.AbstractModelMessage<GeminiResponse>
uno.anahata.asi.gemini.GeminiModelMessage
- All Implemented Interfaces:
PropertyChangeSource, Rebindable
An object-oriented representation of a ModelMessage derived from the Gemini provider.
This class encapsulates the logic for constructing a valid ModelMessage from a
Gemini Content object, ensuring the parent message is created before its parts.
- Author:
- anahata-ai
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final com.google.genai.types.CandidateThe original, native Candidate object from the Google GenAI API.Fields inherited from class BasicPropertyChangeSource
propertyChangeSupport -
Constructor Summary
ConstructorsConstructorDescriptionGeminiModelMessage(Agi agi, String modelId) Constructs a GeminiModelMessage for streaming, without an initial candidate.GeminiModelMessage(Agi agi, String modelId, com.google.genai.types.Candidate candidate, GeminiResponse response) Constructs a GeminiModelMessage, encapsulating the conversion logic. -
Method Summary
Modifier and TypeMethodDescriptionstatic FinishReasontoAnahataFinishReason(com.google.genai.types.FinishReason fr) Maps a Google GenAI FinishReason to the Anahata FinishReason enum.static GroundingMetadatatoAnahataGroundingMetadata(com.google.genai.types.GroundingMetadata gm) Converts Google's GroundingMetadata to Anahata's domain model.toAnahataPart(com.google.genai.types.Part googlePart) Converts a Google GenAI Part to an Anahata AbstractPart within the context of this message.private AbstractToolCalltoAnahataToolCall(com.google.genai.types.FunctionCall googleFc) Converts a Google GenAI FunctionCall to an Anahata AbstractToolCall.Methods inherited from class AbstractModelMessage
addBlobPart, addBlobPart, addBlobPart, addTextPart, addTextPart, appendMetadata, appendRawJson, declineAllPending, executeAllPending, getDevice, getFrom, getRole, getToolCalls, getToolResponses, hasPendingTools, isAutoRunnable, isEffectivelyPruned, isToolPromptMessage, processPendingTools, remove, removePart, setBilledCompletionTokens, setBilledPromptTokens, setFinishReason, setGroundingMetadata, setRawJsonMethods inherited from class AbstractMessage
addPart, asText, createMetadataHeader, getDepth, getEffectiveTokenCount, getIdentityLabel, getParts, getParts, getRemainingDepth, getTokenCount, isAllPinned, isAllPruned, isAnyPinned, isEmpty, isGarbageCollectable, isPrunnableOrRemovable, pinAllParts, pruneAllParts, resetTokenCounts, setAutoAllParts, shouldCreateMetadataMethods 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
-
geminiCandidate
private final transient com.google.genai.types.Candidate geminiCandidateThe original, native Candidate object from the Google GenAI API.
-
-
Constructor Details
-
GeminiModelMessage
-
GeminiModelMessage
public GeminiModelMessage(Agi agi, String modelId, com.google.genai.types.Candidate candidate, GeminiResponse response) Constructs a GeminiModelMessage, encapsulating the conversion logic.- Parameters:
agi- The parent agi session.modelId- The ID of the model that generated the content.candidate- The source Gemini Candidate object.response- The GeminiResponse that returned this message.
-
-
Method Details
-
toAnahataPart
Converts a Google GenAI Part to an Anahata AbstractPart within the context of this message.Implementation details: This method encapsulates the logic previously in PartAdapter and FunctionCallAdapter, handling text, thoughts, tool calls, and multimodal data.
- Parameters:
googlePart- The Google part to convert.- Returns:
- The corresponding Anahata AbstractPart, or null if unsupported.
-
toAnahataToolCall
Converts a Google GenAI FunctionCall to an Anahata AbstractToolCall.- Parameters:
googleFc- The FunctionCall received from the Google API.- Returns:
- A new AbstractToolCall.
-
toAnahataGroundingMetadata
public static GroundingMetadata toAnahataGroundingMetadata(com.google.genai.types.GroundingMetadata gm) Converts Google's GroundingMetadata to Anahata's domain model.- Parameters:
gm- The Google GroundingMetadata object.- Returns:
- The Anahata GroundingMetadata object.
-
toAnahataFinishReason
Maps a Google GenAI FinishReason to the Anahata FinishReason enum.- Parameters:
fr- The Google FinishReason object.- Returns:
- The corresponding Anahata FinishReason.
-

