* Cancels a run that is `in_progress`.
(
key: IntegrationTaskKey,
threadId: string,
runId: string,
options: OpenAIRequestOptions = {}
)
| 443 | * Cancels a run that is `in_progress`. |
| 444 | */ |
| 445 | async cancel( |
| 446 | key: IntegrationTaskKey, |
| 447 | threadId: string, |
| 448 | runId: string, |
| 449 | options: OpenAIRequestOptions = {} |
| 450 | ): Promise<OpenAI.Beta.Threads.Run> { |
| 451 | return this.runTask( |
| 452 | key, |
| 453 | async (client, task, io) => { |
| 454 | const { data, response } = await client.beta.threads.runs |
| 455 | .cancel(threadId, runId, { |
| 456 | idempotencyKey: task.idempotencyKey, |
| 457 | ...options, |
| 458 | }) |
| 459 | .withResponse(); |
| 460 | |
| 461 | task.outputProperties = createTaskOutputProperties(undefined, response.headers); |
| 462 | |
| 463 | return data; |
| 464 | }, |
| 465 | { |
| 466 | name: "Cancel Run", |
| 467 | properties: [ |
| 468 | { label: "threadId", text: threadId }, |
| 469 | { label: "runId", text: runId }, |
| 470 | ], |
| 471 | }, |
| 472 | handleOpenAIError |
| 473 | ); |
| 474 | } |
| 475 | |
| 476 | /** |
| 477 | * When a run has the `status: "requires_action"` and `required_action.type` is |
no test coverage detected