@peopl-health/nexus 2.0.10 → 2.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -16,7 +16,7 @@ const moment = require('moment-timezone');
|
|
|
16
16
|
const mode = process.env.NODE_ENV || 'dev';
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
async function checkRunStatus(assistant, thread_id, run_id, retryCount = 0, maxRetries = 100) {
|
|
19
|
+
async function checkRunStatus(assistant, thread_id, run_id, retryCount = 0, maxRetries = 100, actionHandled = false) {
|
|
20
20
|
try {
|
|
21
21
|
const provider = createProvider({ variant: process.env.VARIANT || 'assistants' });
|
|
22
22
|
const run = await provider.getRun({ threadId: thread_id, runId: run_id });
|
|
@@ -36,15 +36,20 @@ async function checkRunStatus(assistant, thread_id, run_id, retryCount = 0, maxR
|
|
|
36
36
|
if (retryCount >= maxRetries) {
|
|
37
37
|
return false;
|
|
38
38
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
if (!actionHandled) {
|
|
40
|
+
await assistant.handleRequiresAction(run);
|
|
41
|
+
await new Promise(resolve => setTimeout(resolve, 5000));
|
|
42
|
+
return checkRunStatus(assistant, thread_id, run_id, retryCount + 1, maxRetries, true);
|
|
43
|
+
} else {
|
|
44
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
45
|
+
return checkRunStatus(assistant, thread_id, run_id, retryCount + 1, maxRetries, actionHandled);
|
|
46
|
+
}
|
|
42
47
|
} else if (!['completed', 'succeeded'].includes(run.status)) {
|
|
43
48
|
if (retryCount >= maxRetries) {
|
|
44
49
|
return false;
|
|
45
50
|
}
|
|
46
51
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
47
|
-
return checkRunStatus(assistant, thread_id, run_id, retryCount + 1, maxRetries);
|
|
52
|
+
return checkRunStatus(assistant, thread_id, run_id, retryCount + 1, maxRetries, actionHandled);
|
|
48
53
|
} else {
|
|
49
54
|
console.log('Run completed.');
|
|
50
55
|
return true;
|