Gemini.Types.Content (GeminiEx v0.2.1)
View SourceContent type for Gemini API requests and responses.
Summary
Functions
Create content from tool results for function response.
Create content with an image from a file path.
Create content with text and image.
Create content with text.
Types
@type parts() :: [Gemini.Types.Part.t()]
Ordered parts that constitute a single message.
@type role() :: String.t()
The role of the content creator.
@type t() :: %Gemini.Types.Content{parts: [Gemini.Types.Part.t()], role: String.t()}
Functions
@spec from_tool_results([Altar.ADM.ToolResult.t()]) :: t()
Create content from tool results for function response.
Takes a list of validated ToolResult structs and transforms them into a single Content struct with role "tool" containing functionResponse parts.
Parameters
results
- List of Altar.ADM.ToolResult.t() structs
Returns
- Content struct with role "tool" and functionResponse parts
Examples
iex> results = [%Altar.ADM.ToolResult{call_id: "call_123", content: "result"}]
iex> Gemini.Types.Content.from_tool_results(results)
%Gemini.Types.Content{
role: "tool",
parts: [%{functionResponse: %{name: "call_123", response: %{content: "result"}}}]
}
Create content with an image from a file path.
Create content with text and image.
Create content with text.