ask method
Ask the physics specialist a question and return the raw text response.
Send a single-question request to the configured model and return text.
The model field is used to build the request URI for the provider.
Implementation
Future<String> ask(String question, {double temperature = 0.2}) async {
final payload = buildRequestPayload(question, temperature);
final uri = Uri.parse(
'https://generativelanguage.googleapis.com/v1beta2/${model}:generateText',
);
final resp = await http.post(
uri,
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer $apiKey',
},
body: jsonEncode(payload),
);
if (resp.statusCode != 200) {
throw Exception('Request failed: ${resp.statusCode} ${resp.body}');
}
return _extractText(resp.body);
}