243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
|
# File 'lib/gemini_craft/client.rb', line 243
def process(response)
candidates = response["candidates"]
return { content: "", function_calls: [] } if candidates.nil? || candidates.empty?
candidate = candidates.first
content_parts = candidate.dig("content", "parts") || []
text_parts = []
function_calls = []
content_parts.each do |part|
if part["text"]
text_parts << part["text"]
elsif part["functionCall"]
function_calls << {
name: part["functionCall"]["name"],
args: part["functionCall"]["args"] || {}
}
end
end
{
content: text_parts.join(" "),
function_calls: function_calls
}
end
|