Class: Geminize::Models::ToolConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/geminize/models/tool_config.rb

Overview

Represents configuration for tool execution in Gemini API

Constant Summary collapse

EXECUTION_MODES =

Valid execution modes for tools

["AUTO", "MANUAL", "NONE"].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(execution_mode = "AUTO") ⇒ ToolConfig

Initialize a new tool configuration

Parameters:

  • execution_mode (String) (defaults to: "AUTO")

    The execution mode for tools

Raises:



16
17
18
19
# File 'lib/geminize/models/tool_config.rb', line 16

def initialize(execution_mode = "AUTO")
  @execution_mode = execution_mode
  validate!
end

Instance Attribute Details

#execution_modeString (readonly)

Returns The execution mode for tools.

Returns:

  • (String)

    The execution mode for tools



11
12
13
# File 'lib/geminize/models/tool_config.rb', line 11

def execution_mode
  @execution_mode
end

Instance Method Details

#to_hHash

Alias for to_hash

Returns:

  • (Hash)

    The tool configuration as a hash



47
48
49
# File 'lib/geminize/models/tool_config.rb', line 47

def to_h
  to_hash
end

#to_hashHash

Convert the tool configuration to a hash for API requests

Returns:

  • (Hash)

    The tool configuration as a hash



37
38
39
40
41
42
43
# File 'lib/geminize/models/tool_config.rb', line 37

def to_hash
  {
    function_calling_config: {
      mode: @execution_mode
    }
  }
end

#validate!Boolean

Validate the tool configuration

Returns:

  • (Boolean)

    true if validation passes

Raises:



24
25
26
27
28
29
30
31
32
33
# File 'lib/geminize/models/tool_config.rb', line 24

def validate!
  unless EXECUTION_MODES.include?(@execution_mode)
    raise Geminize::ValidationError.new(
      "Invalid execution mode: #{@execution_mode}. Must be one of: #{EXECUTION_MODES.join(", ")}",
      "INVALID_ARGUMENT"
    )
  end

  true
end