executeGenAIRequest function
Implementation
Future<String?> executeGenAIRequest(AIRequestModel? aiRequestModel) async {
final httpRequestModel = aiRequestModel?.httpRequestModel;
if (httpRequestModel == null) {
debugPrint("executeGenAIRequest -> httpRequestModel is null");
return null;
}
final (response, _, _) = await sendHttpRequest(
nanoid(),
APIType.rest,
httpRequestModel,
);
if (response == null) return null;
if (response.statusCode == 200) {
final data = jsonDecode(response.body);
return aiRequestModel?.getFormattedOutput(data);
} else {
debugPrint('LLM_EXCEPTION: ${response.statusCode}\n${response.body}');
return null;
}
}