class

Gemini::GenerativeModel

Inherits JSON::Serializable < Reference < Object

Generates a model response given an input.

API Reference

Constants

HEADERS = HTTP::Headers {"Content-Type" => "application/json"}

Constructors

new(model_name : String, system_instruction : Gemini::Content | Nil = nil, generation_config : Gemini::GenerationConfig | Nil = nil, safety_settings : Nil | Array(Gemini::SafetySetting) = nil, tools : Nil | Array(Gemini::Tool) = nil, tool_config : Gemini::ToolConfig | Nil = nil, cached_content : Nil | String = nil)

Configuration parameters are optional and non-initialized, so they must be defined later

Source
new(*, __pull_for_json_serializable pull : JSON::PullParser)
Source

Instance methods

cached_content

The name of the content cached to use as context to serve the prediction. (Optional)

Source
cached_content=(cached_content : String | Nil)

The name of the content cached to use as context to serve the prediction. (Optional)

Source
contents

The content of the current conversation with the model. (Required) For single-turn queries, this is a single instance. For multi-turn queries like chat, this is a repeated field that contains the conversation history and the latest request.

Source
contents=(contents : Array(Content) | Deque(Content) | Content)

The content of the current conversation with the model. (Required) For single-turn queries, this is a single instance. For multi-turn queries like chat, this is a repeated field that contains the conversation history and the latest request.

Source
contents?

The content of the current conversation with the model. (Required) For single-turn queries, this is a single instance. For multi-turn queries like chat, this is a repeated field that contains the conversation history and the latest request.

Source
generate_content(text : String) : GenerateContentResponse
Source
generate_content(data : Array | Deque) : GenerateContentResponse
Source
generation_config

Configuration options for model generation and outputs. (Optional)

Source
generation_config=(generation_config : GenerationConfig | Nil)

Configuration options for model generation and outputs. (Optional)

Source
safety_settings

A list of unique SafetySetting instances for blocking unsafe content. (Optional)

Source
safety_settings=(safety_settings : Array(SafetySetting) | Nil)

A list of unique SafetySetting instances for blocking unsafe content. (Optional)

Source
system_instruction

Developer set system instruction(s). Currently, text only. (Optional)

API Reference

Source
system_instruction=(system_instruction : Content | Nil)

Developer set system instruction(s). Currently, text only. (Optional)

API Reference

Source
tool_config

Tool configuration for any Tool specified in the request. Refer to the Function calling guide for a usage example. (Optional)

Source
tool_config=(tool_config : ToolConfig | Nil)

Tool configuration for any Tool specified in the request. Refer to the Function calling guide for a usage example. (Optional)

Source
tools

A list of Tools the Model may use to generate the next response. (Optional)

Source
tools=(tools : Array(Tool) | Nil)

A list of Tools the Model may use to generate the next response. (Optional)

Source