@peopl-health/nexus 4.5.24 → 4.5.25
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.
|
@@ -518,6 +518,7 @@ class NexusMessaging {
|
|
|
518
518
|
}
|
|
519
519
|
|
|
520
520
|
async processInstruction(code, instruction, role = 'developer', { triggeredBy } = {}) {
|
|
521
|
+
const assistantId = await this._getThreadAssistantId(code);
|
|
521
522
|
const messageData = {
|
|
522
523
|
pushName: 'Instruction',
|
|
523
524
|
code,
|
|
@@ -526,6 +527,7 @@ class NexusMessaging {
|
|
|
526
527
|
fromMe: true,
|
|
527
528
|
processed: true,
|
|
528
529
|
origin: 'instruction',
|
|
530
|
+
assistantId,
|
|
529
531
|
raw: { role },
|
|
530
532
|
triggeredBy: triggeredBy || null,
|
|
531
533
|
silent: true,
|
|
@@ -554,6 +556,7 @@ class NexusMessaging {
|
|
|
554
556
|
const thread = await Thread.findOne({ code }).lean();
|
|
555
557
|
if (!thread) return null;
|
|
556
558
|
|
|
559
|
+
const assistantId = await this._getThreadAssistantId(code);
|
|
557
560
|
const normalizedMessages = Array.isArray(messages) ? messages : [messages];
|
|
558
561
|
|
|
559
562
|
for (let i = 0; i < normalizedMessages.length; i++) {
|
|
@@ -566,6 +569,7 @@ class NexusMessaging {
|
|
|
566
569
|
fromMe: true,
|
|
567
570
|
processed: true,
|
|
568
571
|
origin: 'system',
|
|
572
|
+
assistantId,
|
|
569
573
|
raw: { role },
|
|
570
574
|
triggeredBy: triggeredBy || null,
|
|
571
575
|
silent: true,
|
|
@@ -593,6 +597,11 @@ class NexusMessaging {
|
|
|
593
597
|
return result?.output || null;
|
|
594
598
|
}
|
|
595
599
|
|
|
600
|
+
async _getThreadAssistantId(code) {
|
|
601
|
+
const thread = await Thread.findOne({ code }).select('assistant_id prompt_id').lean();
|
|
602
|
+
return thread?.prompt_id || thread?.assistant_id || null;
|
|
603
|
+
}
|
|
604
|
+
|
|
596
605
|
async _processMessages(chatId, processingFn, shouldFinalize = () => true) {
|
|
597
606
|
const query = { numero: chatId, from_me: false, processed: false };
|
|
598
607
|
const unprocessed = await getMessages(query, { select: '_id' });
|