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
|