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

Instance Method Summary collapse

Instance Method Details

#perform_model_completion!(model_completion, &block) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/models/raif/llms/google.rb', line 8

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