class Gemini::GenerativeModel

Overview

Generates a model response given an input.

API Reference

Included Modules

Defined in:

gemini/models.cr

Constant Summary

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

Constructors

Instance Method Summary

Constructor Detail

def self.new(pull : JSON::PullParser) #

def self.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


Instance Method Detail

def cached_content : String | Nil #

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


def cached_content=(cached_content : String | Nil) #

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


def 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.


def 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.


def contents? : Array(Content) | Deque(Content) | Content | Nil #

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.


def generate_content(text : String) : GenerateContentResponse #

def generate_content(contents : Array(Gemini::Content) | Deque(Gemini::Content) | Gemini::Content | Nil) : GenerateContentResponse #

def generation_config : GenerationConfig | Nil #

Configuration options for model generation and outputs. (Optional)


def generation_config=(generation_config : GenerationConfig | Nil) #

Configuration options for model generation and outputs. (Optional)


def safety_settings : Array(SafetySetting) | Nil #

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


def safety_settings=(safety_settings : Array(SafetySetting) | Nil) #

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


def system_instruction : Content | Nil #

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

API Reference


def system_instruction=(system_instruction : Content | Nil) #

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

API Reference


def tool_config : ToolConfig | Nil #

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


def 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)


def tools : Array(Tool) | Nil #

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


def tools=(tools : Array(Tool) | Nil) #

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