Hi,
I'm working on a chatbot (Gemini) running on an ESP32, and have got it working at a basic level - but would like to add system instructions and modified safety features. My problem is that I cannot seem to construct a valid http payload as I am unsure about the syntax.
This works ok:
String payload = String("{"contents": [{"parts":[{"text":" + res + "}]}],"generationConfig": {"maxOutputTokens": " + (String)Gemini_Max_Tokens + "}}");
but can anyone help with adding the system instruction (to respond as an silly person), and the safety settings? I am getting lost amongst the { and ].
Thanks for your reply - I had a look, but am sorry to say that it has not helped - still stuck on the syntax for adding the extra params. If I do manage this, I will post the answer.
Thanks all..I've cracked it... Had a light bulb moment and submitted my query to the Gemini API itself - which returned a working code in3 seconds. Sigh.
Should anyone writing a ESP32 based chatbot find their way here, this is the vital line:
String payload = String("{"contents": [{"parts":[{"text":"where are you from?"} ]}],"safetySettings": [{"category":"HARM_CATEGORY_HARASSMENT","threshold":"BLOCK_ALL"},{"category":"HARM_CATEGORY_HATE_SPEECH","threshold":"BLOCK_ALL"},{"category":"HARM_CATEGORY_DANGEROUS_CONTENT","threshold":"BLOCK_ALL"}],"systemInstruction":{"role":"user","parts":[{"text":"answer as an angry robot"}]},"generationConfig":{"temperature":1.8,"maxOutputTokens":" + (String)Gemini_Max_Tokens + "}}");