generateTextAndImages method
Future<GeminiAIHttpResponse>
generateTextAndImages({
- required String query,
- required String apiKey,
- required dynamic image,
- required GenerationConfig? config,
- required List<
SafetySettings> ? safetySettings, - String model = 'gemini-pro-vision',
Implementation
Future<GeminiAIHttpResponse> generateTextAndImages({
required String query,
required String apiKey,
required dynamic image,
required GenerationConfig? config,
required List<SafetySettings>? safetySettings,
String model = 'gemini-pro-vision',
}) async {
try {
final response = await _dio.post(
'${Constants.geminiAIEndpoint}/$model:generateContent',
queryParameters: {'key': apiKey},
data: {
"contents": [
{
"parts": [
{"text": query},
{
"inline_data": {"mime_type": "image/jpeg", "data": image}
},
],
}
],
"safetySettings": _convertSafetySettings(safetySettings ?? []),
"generationConfig": config?.toJson(),
},
);
return GeminiAIHttpResponse.fromJson(response.data);
} catch (error, s) {
print("this is throwing an error in $s");
throw _handleError(error);
}
}