I'm wondering if I'm missing a configuration. My response is broken up into numerous parts. I know I could combine them, but I'm wondering why this result is different than what I get when I run a curl command to hit the API.
client = Gemini.new(
credentials: {
service: "generative-language-api",
api_key: ENV["GEMINI_API_KEY"],
},
options: { model: "gemini-pro", stream: false },
)
result = client.stream_generate_content({
contents: { role: "user", parts: { text: "Write an essay on the history of Canada." } },
})
{
"candidates"=>[
{
"content"=>{
"parts"=>[
{
"text"=>"The history of Canada is a rich and complex tapestry of Indigenous civilizations, European exploration"
}
],
"role"=>"model"
},
"finishReason"=>"STOP",
"index"=>0,
"safetyRatings"=>[
{
"category"=>"HARM_CATEGORY_SEXUALLY_EXPLICIT",
"probability"=>"NEGLIGIBLE"
},
{
"category"=>"HARM_CATEGORY_HATE_SPEECH",
"probability"=>"NEGLIGIBLE"
},
{
"category"=>"HARM_CATEGORY_HARASSMENT",
"probability"=>"NEGLIGIBLE"
},
{
"category"=>"HARM_CATEGORY_DANGEROUS_CONTENT",
"probability"=>"NEGLIGIBLE"
}
]
}
],
"promptFeedback"=>{
"safetyRatings"=>[
{
"category"=>"HARM_CATEGORY_SEXUALLY_EXPLICIT",
"probability"=>"NEGLIGIBLE"
},
{
"category"=>"HARM_CATEGORY_HATE_SPEECH",
"probability"=>"NEGLIGIBLE"
},
{
"category"=>"HARM_CATEGORY_HARASSMENT",
"probability"=>"NEGLIGIBLE"
},
{
"category"=>"HARM_CATEGORY_DANGEROUS_CONTENT",
"probability"=>"NEGLIGIBLE"
}
]
}
}{
"candidates"=>[
{
"content"=>{
"parts"=>[
{
"text"=>", colonization, confederation, and nation-building. Spanning thousands of years, it is a story of diverse peoples, cultures, and events that have shaped"
}
],
"role"=>"model"
},
"finishReason"=>"STOP",
"index"=>0,
"safetyRatings"=>[
{
"category"=>"HARM_CATEGORY_SEXUALLY_EXPLICIT",
"probability"=>"NEGLIGIBLE"
},
{
"category"=>"HARM_CATEGORY_HATE_SPEECH",
"probability"=>"NEGLIGIBLE"
},
{
"category"=>"HARM_CATEGORY_HARASSMENT",
"probability"=>"NEGLIGIBLE"
},
{
"category"=>"HARM_CATEGORY_DANGEROUS_CONTENT",
"probability"=>"NEGLIGIBLE"
}
]
}
]
} ... etc ...
{
"candidates"=>[
{
"content"=>{
"parts"=>[
{
"text"=>"th century, Canada played a major role in both World Wars, and its contributions helped to establish the country as a respected member of the international community. After the Second World War, Canada experienced a period of rapid economic growth and social change, leading to the Quiet Revolution in Quebec and the rise of a more diverse and multicultural society.\n\nToday, Canada is a modern, democratic, and prosperous country with a rich history and culture. It is a nation built on the principles of peace, order, and good government, and it continues to play an active role in global affairs, promoting peace, security, and human rights around the world."
}
],
"role"=>"model"
},
"finishReason"=>"STOP",
"index"=>0,
"safetyRatings"=>[
{
"category"=>"HARM_CATEGORY_SEXUALLY_EXPLICIT",
"probability"=>"NEGLIGIBLE"
},
{
"category"=>"HARM_CATEGORY_HATE_SPEECH",
"probability"=>"NEGLIGIBLE"
},
{
"category"=>"HARM_CATEGORY_HARASSMENT",
"probability"=>"NEGLIGIBLE"
},
{
"category"=>"HARM_CATEGORY_DANGEROUS_CONTENT",
"probability"=>"NEGLIGIBLE"
}
]
}
]
}