Class: Aigen::Google::Content
- Inherits:
-
Object
- Object
- Aigen::Google::Content
- Defined in:
- lib/aigen/google/content.rb
Overview
Content represents text, image, or multimodal content for Gemini API requests. Provides builder methods for creating content and serialization to API format.
Class Method Summary collapse
-
.image(data:, mime_type:) ⇒ Content
Creates an image content instance with Base64-encoded data.
-
.text(text) ⇒ Content
Creates a text content instance.
Instance Method Summary collapse
-
#initialize(parts) ⇒ Content
constructor
Initializes a Content instance with an array of parts.
-
#to_h ⇒ Hash
Serializes the content to Gemini API format.
Constructor Details
#initialize(parts) ⇒ Content
Initializes a Content instance with an array of parts.
66 67 68 |
# File 'lib/aigen/google/content.rb', line 66 def initialize(parts) @parts = parts end |
Class Method Details
.image(data:, mime_type:) ⇒ Content
Creates an image content instance with Base64-encoded data.
45 46 47 48 49 50 51 52 |
# File 'lib/aigen/google/content.rb', line 45 def self.image(data:, mime_type:) new([{ inline_data: { mime_type: mime_type, data: data } }]) end |
.text(text) ⇒ Content
Creates a text content instance.
31 32 33 |
# File 'lib/aigen/google/content.rb', line 31 def self.text(text) new([{text: text}]) end |
Instance Method Details
#to_h ⇒ Hash
Serializes the content to Gemini API format.
77 78 79 |
# File 'lib/aigen/google/content.rb', line 77 def to_h {parts: @parts} end |