mirror of
https://github.com/spchcap/speech.capital.git
synced 2026-01-13 16:18:06 +00:00
Refactor: Repeat Gemini instructions for clarity
This commit is contained in:
@@ -47,7 +47,7 @@ export async function onRequestPost({request,env}){
|
||||
const{sub,title,link,content}=body;
|
||||
if(!sub||!title)return json({error:'Missing fields'},{status:400},request);
|
||||
|
||||
const mod=await fetch(`https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-lite:generateContent?key=${env.GOOGLE_KEY}`,{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({contents:[{parts:[{text:`Is this content permissible for a public forum that values free speech, even if it's controversial? Offensive content is okay, but illegal content, spam, or direct threats are not. Respond ONLY "yes" or "no".\n\n${title}\n\n${content||''}`}]}]})});
|
||||
const mod=await fetch(`https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-lite:generateContent?key=${env.GOOGLE_KEY}`,{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({contents:[{parts:[{text:`Is this content permissible for a public forum that values free speech, even if it's controversial? Offensive content is okay, but illegal content, spam, or direct threats are not. Respond ONLY "yes" or "no".\n\n${title}\n\n${content||''}\n\nReminder: be lenient. Only reject illegal content, spam, or direct threats. Respond ONLY "yes" or "no".`}]}]})});
|
||||
if(!mod.ok){const err=await mod.text();return json({error:{message:`Moderation failed: ${err}`}},{status:500},request)}
|
||||
if(!(await mod.json()).candidates?.[0]?.content.parts[0].text.trim().toLowerCase().includes('yes'))return json({error:{message:'Post rejected by Gemini 2.5 Flash Lite.'}},{status:400},request);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user