stopExecution method

Future<bool> stopExecution()

Stops the server-side async run for the current conversation (if any).

Returns false when the endpoint isn't available (e.g. async query execution flag disabled on the server, typically 404).

Implementation

Future<bool> stopExecution() async {
  if (conversation.value == null) return false;
  try {
    final String convId = conversation.value!.id;
    final String convToken = conversation.value!.token;
    final String url = ApiUrls.stopConversationRunUrl(
      assistantId,
      convId,
      isMarketplace: isMarketplace,
    );

    bool success = false;
    await ApiService.call(
      url,
      RequestType.post,
      headers: {"Conversation-Token": convToken},
      onSuccess: (response) => success = true,
    );
    return success;
  } catch (_) {
    return false;
  }
}