When I send anything(literally), gemini returns data in unusual manner:
()=>{if(t.candidates&&t.candidates.length>0){if(t.candidates.length>1&&console.warn(
This response had ${t.candidates.length} candidates. Returning text from the first candidate only. Access response.candidates directly to use the other candidates.
),R(t.candidates[0]))throw new h(${N(t)}
,t);return function(t){var e,n,s,o;const i=;if(null===(n=null===(e=t.candidates)||void 0===e?void 0:e[0].content)||void 0===n?void 0:n.parts)for(const e of null===(o=null===(s=t.candidates)||void 0===s?void 0:s[0].content)||void 0===o?void 0:o.parts)e.text&&i.push(e.text),e.executableCode&&i.push(“\n"+e.executableCode.language+"\n"+e.executableCode.code+"\n
\n”),e.codeExecutionResult&&i.push(“\n\n"+e.codeExecutionResult.output+"\n
\n”);return i.length>0?i.join(“”):“”}(t)}if(t.promptFeedback)throw new h(Text not available. ${N(t)}
,t);return""}
My code is :
async function sendToGemini(htmls) {
const model = genAi.getGenerativeModel({ model: “gemini-1.5-flash-latest” });
const result = await model.generateContent(Fix the errors in this HTML code and return only the corrected HTML:\n${htmls}
);
const responseText = result.response && result.response.text ? decodeURIComponent(result.response.text) : “”;
return responseText;
}
Please help me to fix this