sendMessage method
This method will be used to send the message to the external service and return the message to the application.
@param message The message to send to the external service. @param projectId The project ID to send to the external service.
Implementation
@override
Future<AiDocSearchResponse> sendMessage(
{required String message, dynamic args}) async {
Uri url = Uri.parse("$apiEndpoint/doc-search/$projectId").replace(
queryParameters: {
"query": message,
},
);
var response = await http.get(
url,
headers: {
"Content-Type": "application/json",
"apiKey": apiKey,
},
);
if (response.statusCode == 200) {
return _aiDocSearchResponseFromJson(response.body);
} else {
response.body;
throw Exception('Failed to load message');
}
}