Gemini.Types.Content (GeminiEx v0.2.1)

View Source

Content type for Gemini API requests and responses.

Summary

Types

Ordered parts that constitute a single message.

The role of the content creator.

t()

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

parts()

@type parts() :: [Gemini.Types.Part.t()]

Ordered parts that constitute a single message.

role()

@type role() :: String.t()

The role of the content creator.

t()

@type t() :: %Gemini.Types.Content{parts: [Gemini.Types.Part.t()], role: String.t()}

Functions

from_tool_results(results)

@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"}}}]
}

image(path, role \\ "user")

@spec image(String.t(), String.t()) :: t()

Create content with an image from a file path.

multimodal(text, image_data, mime_type, role \\ "user")

@spec multimodal(String.t(), String.t(), String.t(), String.t()) :: t()

Create content with text and image.

text(text, role \\ "user")

@spec text(String.t(), String.t()) :: t()

Create content with text.