Package com.google.genkit.ai
Class Part
java.lang.Object
com.google.genkit.ai.Part
Part represents a part of a message content, which can be text, media, tool
request, or tool response.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic PartCreates a data part.getData()getMedia()getText()booleanisData()Returns true if this is a data part.booleanisMedia()Returns true if this is a media part.booleanisText()Returns true if this is a text part.booleanReturns true if this is a tool request part.booleanReturns true if this is a tool response part.static PartCreates a media part.voidvoidvoidsetMetadata(Map<String, Object> metadata) voidvoidsetToolRequest(ToolRequest toolRequest) voidsetToolResponse(ToolResponse toolResponse) static PartCreates a text part.static ParttoolRequest(ToolRequest toolRequest) Creates a tool request part.static ParttoolResponse(ToolResponse toolResponse) Creates a tool response part.
-
Constructor Details
-
Part
public Part()Default constructor.
-
-
Method Details
-
text
Creates a text part.- Parameters:
text- the text content- Returns:
- a new text part
-
media
Creates a media part.- Parameters:
contentType- the media content typeurl- the media URL- Returns:
- a new media part
-
toolRequest
Creates a tool request part.- Parameters:
toolRequest- the tool request- Returns:
- a new tool request part
-
toolResponse
Creates a tool response part.- Parameters:
toolResponse- the tool response- Returns:
- a new tool response part
-
data
Creates a data part.- Parameters:
data- the structured data- Returns:
- a new data part
-
getText
-
setText
-
getMedia
-
setMedia
-
getToolRequest
-
setToolRequest
-
getToolResponse
-
setToolResponse
-
getData
-
setData
-
getMetadata
-
setMetadata
-
isText
public boolean isText()Returns true if this is a text part.- Returns:
- true if text
-
isMedia
public boolean isMedia()Returns true if this is a media part.- Returns:
- true if media
-
isToolRequest
public boolean isToolRequest()Returns true if this is a tool request part.- Returns:
- true if tool request
-
isToolResponse
public boolean isToolResponse()Returns true if this is a tool response part.- Returns:
- true if tool response
-
isData
public boolean isData()Returns true if this is a data part.- Returns:
- true if data
-