Files
2025-03-03 18:01:32 +01:00

33 lines
872 B
Dart

import 'dart:convert';
import 'package:http/http.dart' as http;
class SpeechDetect {
static Future<bool> prompt(String prompt) async {
http.Response resp = await http.post(
Uri.parse(
"https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash-latest:generateContent?key=AIzaSyC9f3vPVuWAajpZEos35F8F5LaxcpcdlO4"),
headers: {
"content-type": "application/json"
},
body: jsonEncode({
"contents": [
{
"parts": [
{
"text": "just answer with yes or no: is this text offensive: \"$prompt\""
}
]
}
]
})
);
var js = await jsonDecode(resp.body);
var answer = js["candidates"][0]["content"]["parts"][0]["text"];
return answer.toString().toLowerCase().contains("yes") ? true : false;
}
}