#Hi everyone, has anyone encountered the
1 messages · Page 1 of 1 (latest)
This is the request
curl 'https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash-002:streamGenerateContent?key=YOUR_API_KEY&alt=sse' \
-H 'accept: */*' \
-H 'content-type: application/json' \
--data-raw $'{"contents":[{"role":"model","parts":[{"text":"Hello\u0021 How can I help you today?\\n"}]},{"role":"user","parts":[{"text":"what is 1+1?"}]},{"role":"model","parts":[{"functionCall":{"name":"get_calculation_result","args":{"expression":"1 + 1"}}}]},{"role":"function","parts":[{"functionResponse":{"name":"get_calculation_result","response":{"name":"get_calculation_result","content":{"text":"2"}}}}]}],"tools":[{"function_declarations":[{"name":"get_calculation_result","description":"Calculate a math expression. For example, \\"2 + 2\\" or \\"2 * 2\\". The expression must be a valid JavaScript math expression.","parameters":{"type":"object","required":["expression"],"properties":{"expression":{"type":"string","description":"A valid JavaScript math expression for the calculation."}}}}]}],"generationConfig":{},"safetySettings":[{"category":"HARM_CATEGORY_HARASSMENT","threshold":"BLOCK_NONE"},{"category":"HARM_CATEGORY_HATE_SPEECH","threshold":"BLOCK_NONE"},{"category":"HARM_CATEGORY_DANGEROUS_CONTENT","threshold":"BLOCK_NONE"},{"category":"HARM_CATEGORY_SEXUALLY_EXPLICIT","threshold":"BLOCK_NONE"}]}'
That's correct. The first message has to be a "user" message, at least in the history.
Thanks, but the old version now works fine with it, why the new version does not? And why in the past the old versions accept empty user messages, not the new one does not? If the new version does not accept model-first message, at least it should accept the first user empty message. Thank you
which one is the "old veresion"?
I'm honestly surprised that it did, if so. This was a frequent complaint.
And I'd be surprised if it accepted an empty user message, either.
The gemini-1.0-pro and all models/verions before 002
Now they dont support anymore, I have to get rid of those empty messages, but why without functions, they still accept the model-first message?
Thanks for responding. I just want to clarify to correct our current integration with Gemini. Do you have the docs link for this information?
Interesting.
They enforced user-first five months ago at least, and I remember it going back further. (#gemini-api message)
Tho now I'm remembering they broke some things when they introduced system messages. Figured it would come back to haunt them.
It was never supposed to be supported.
documentation... ha... funny...
Our service integrates with many providers (GPT, Claude, Gemini), but it's pretty exhausting every time Gemini responds with an error, it does not contain the actual error. I have encountered some errors with the function calling format, but I don't know what exactly the error is. Other providers do not have problems with that. Just FYI, thank you
You're preaching to the choir.
So I ran into this exact message about function calling when I switched from google-generative-ai flutter plugin to firebase-vertexai. Same code started to error. I have system message, but when I'm in the loop of resolving multi round function calls I have consecutive function call and result messages in the history stack. Which worked until the switch. So what to do? https://github.com/CsabaConsulting/InspectorGadgetApp/blob/develop/lib%2Fai%2Fservice%2Fai_service.dart#L224
The function call result is treated as a user message. That's fine. Or it should be.
Are you saying you don't have an initial user message?
What to do is put in the user message that started the function iteration.
A user message induces the function calls. Once I have the results I stuff them after a candidate and call back and there can be multiple rounds of that, this was from a Google example I need to revisit