Hi,
I’m building a simple chatbot using the Gemini api on an esp32 using the Arduino IDE. I have it working nicely, but only with basic settings. I use POST to send a payload string, which is constructed thus:
where ‘res’ is the string typed by the user (eventually, this will come from speech recognition). This works fine, but I want to add a system instruction to alter the charcter of the response (eg to that of an angry robot), and also modify the safety settings - but I cannot figure out how to include these in the above line of code. Could I please ask if there are any Ardunio experts willing to help out - many thanks.
Thankyou both, for your replies. I’ve read the documents to which you refer, but I’m sorry to say that they have not helped me (for now). Whilst I understand some of this, I am stuck on trying to get the required params into the format shown in my original post - will have another go later, thanks again.
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 + “}}”);