@peopl-health/nexus 3.2.5 → 3.2.6
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.
|
@@ -19,8 +19,8 @@ const runAssistantAndWait = async ({
|
|
|
19
19
|
message = null,
|
|
20
20
|
runConfig = {}
|
|
21
21
|
}) => {
|
|
22
|
-
if (!thread
|
|
23
|
-
throw new Error('runAssistantAndWait requires a thread
|
|
22
|
+
if (!thread) {
|
|
23
|
+
throw new Error('runAssistantAndWait requires a thread');
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
if (!assistant) {
|
|
@@ -282,9 +282,7 @@ class OpenAIResponsesProvider {
|
|
|
282
282
|
promptVersion = null,
|
|
283
283
|
promptVariables = null
|
|
284
284
|
} = {}) {
|
|
285
|
-
try {
|
|
286
|
-
const id = this._ensurethreadId(threadId);
|
|
287
|
-
|
|
285
|
+
try {
|
|
288
286
|
let input = context || this._convertItemsToApiFormat(additionalMessages);
|
|
289
287
|
let allToolsExecuted = [];
|
|
290
288
|
let totalRetries = 0;
|
|
@@ -313,7 +311,7 @@ class OpenAIResponsesProvider {
|
|
|
313
311
|
const functionCalls = response.output.filter(item => item.type === 'function_call');
|
|
314
312
|
|
|
315
313
|
if (functionCalls.length > 0) {
|
|
316
|
-
const { outputs, toolsExecuted } = await handleFunctionCallsUtil(functionCalls, assistant, toolMetadata || { thread_id:
|
|
314
|
+
const { outputs, toolsExecuted } = await handleFunctionCallsUtil(functionCalls, assistant, toolMetadata || { thread_id: threadId, assistant_id: assistantId });
|
|
317
315
|
|
|
318
316
|
input.push(...response.output);
|
|
319
317
|
input.push(...outputs);
|
|
@@ -327,7 +325,7 @@ class OpenAIResponsesProvider {
|
|
|
327
325
|
|
|
328
326
|
return {
|
|
329
327
|
...finalResponse,
|
|
330
|
-
thread_id:
|
|
328
|
+
thread_id: threadId,
|
|
331
329
|
assistant_id: assistantId,
|
|
332
330
|
object: finalResponse.object || 'response',
|
|
333
331
|
tools_executed: allToolsExecuted,
|
|
@@ -161,10 +161,12 @@ const replyAssistantCore = async (code, message_ = null, thread_ = null, runOpti
|
|
|
161
161
|
const messagesStart = Date.now();
|
|
162
162
|
const beforeCheckpoint = message_?.createdAt ?
|
|
163
163
|
(message_.createdAt.$date ? new Date(message_.createdAt.$date) : message_.createdAt) : null;
|
|
164
|
-
const lastMessage = await getLastNMessages(code, 1, beforeCheckpoint
|
|
164
|
+
const lastMessage = await getLastNMessages(code, 1, beforeCheckpoint, {
|
|
165
|
+
query: { from_me: false }
|
|
166
|
+
});
|
|
165
167
|
timings.get_messages_ms = Date.now() - messagesStart;
|
|
166
168
|
|
|
167
|
-
if (!lastMessage || lastMessage.length === 0
|
|
169
|
+
if (!lastMessage || lastMessage.length === 0) {
|
|
168
170
|
logger.info('[replyAssistantCore] No relevant data found for this assistant.');
|
|
169
171
|
return null;
|
|
170
172
|
}
|
|
@@ -226,7 +228,10 @@ const replyAssistantCore = async (code, message_ = null, thread_ = null, runOpti
|
|
|
226
228
|
}
|
|
227
229
|
}
|
|
228
230
|
|
|
229
|
-
if (!patientMsg || finalThread.stopped)
|
|
231
|
+
if (!patientMsg || finalThread.stopped) {
|
|
232
|
+
logger.info('[replyAssistantCore] Skipping AI processing', { patientMsg, stopped: finalThread.stopped, code });
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
230
235
|
|
|
231
236
|
const assistant = getAssistantById(finalThread.getAssistantId(), finalThread);
|
|
232
237
|
const runStart = Date.now();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peopl-health/nexus",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.6",
|
|
4
4
|
"description": "Core messaging and assistant library for WhatsApp communication platforms",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"whatsapp",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"@opentelemetry/sdk-trace-node": "1.28.0",
|
|
85
85
|
"@opentelemetry/semantic-conventions": "1.28.0",
|
|
86
86
|
"airtable": "^0.12.2",
|
|
87
|
-
"aws-sdk": "2.
|
|
87
|
+
"aws-sdk": "2.1693.0",
|
|
88
88
|
"axios": "^1.5.0",
|
|
89
89
|
"dotenv": "^16.6.1",
|
|
90
90
|
"moment-timezone": "^0.5.43",
|