Class: Raif::Llms::Google

Inherits:
Raif::Llm
  • Object
show all
Includes:
Concerns::Llms::Google::MessageFormatting, Concerns::Llms::Google::ResponseToolCalls, Concerns::Llms::Google::ToolFormatting
Defined in:
app/models/raif/llms/google.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.cache_read_input_token_cost_multiplierObject



8
9
10
# File 'app/models/raif/llms/google.rb', line 8

def self.cache_read_input_token_cost_multiplier
  0.25
end

Instance Method Details

#perform_model_completion!(model_completion, &block) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/models/raif/llms/google.rb', line 12

def perform_model_completion!(model_completion, &block)
  params = build_request_parameters(model_completion)
  endpoint = build_endpoint(model_completion)

  response = connection.post(endpoint) do |req|
    req.body = params
    req.options.on_data = streaming_chunk_handler(model_completion, &block) if model_completion.stream_response?
  end

  unless model_completion.stream_response?
    update_model_completion(model_completion, response.body)
  end

  model_completion
end

#supports_faithful_required_tool_choice?(available_model_tools) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
31
32
33
# File 'app/models/raif/llms/google.rb', line 28

def supports_faithful_required_tool_choice?(available_model_tools)
  super && Array(available_model_tools).none? do |tool|
    tool_class = tool.is_a?(String) ? tool.constantize : tool
    tool_class.provider_managed?
  end
end