#Hi everyone, has anyone encountered the

1 messages · Page 1 of 1 (latest)

whole crag
#

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"}]}'
errant marsh
#

That's correct. The first message has to be a "user" message, at least in the history.

whole crag
errant marsh
#

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.

whole crag
#

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?

errant marsh
#

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.

errant marsh
whole crag
#

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

errant marsh
#

You're preaching to the choir.

sage crypt
#

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

GitHub

Open Multi-Modal Personal Assistant. Contribute to CsabaConsulting/InspectorGadgetApp development by creating an account on GitHub.

errant marsh
sage crypt
#

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

sage crypt
#

So maybe I don't need to prepend the first candidate any more in front of the function result parts?