Skip to main content

$rag.query.cancelProcessing

The method cancels the response generation in the knowledge base.

caution

The method is available only in the ECMAScript 6 runtime and is asynchronous.

Syntax

The method accepts the following arguments:

ArgumentTypeDescriptionRequired
secretNameStringName of the knowledge base secret.Yes
queryIdNumber

Identifier of the request for response generation.

Use the identifier returned by the $rag.query.generateAnswerAsync method.
Yes
timeoutNumber

Timeout in milliseconds for the method execution. If the timeout is exceeded, an error will occur.

By default, the timeout is not set.
No

Specify the arguments in order:

await $rag.query.cancelProcessing("MyKnowledgeHub", 12345, 5000);

Return value

The method returns an object with information about the response generation request. If the request is canceled successfully, the status is CANCELED.

{
"id": 12345,
"request": "What does the Example service do?",
"status": "CANCELED",
"createdAt": "2024-12-03T15:16:11.404690Z",
"response": null,
"updatedAt": "2024-12-03T15:16:11.404692Z",
"comment": null
}

The object has the same format as the response to the POST /api/knowledge-hub/query/{queryId}/cancel request in the Tovie Data Agent API.

How to use

state: Answer
intent!: /question
scriptEs6:
const ragRequest = await $rag.query.generateAnswerAsync("MyKnowledgeHub", $request.query);

var cancelRequest = await $rag.query.cancelProcessing("MyKnowledgeHub", ragRequest.id);
$reactions.answer("Request status: " + cancelRequest.status)

In this state:

  1. The bot creates a request and saves its identifier.
  2. The bot cancels the request by this identifier and sends the status to the user.