@peopl-health/nexus 2.1.1 → 2.1.3
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.
|
@@ -181,8 +181,6 @@ class BaseAssistant {
|
|
|
181
181
|
this.thread = {
|
|
182
182
|
...conversation,
|
|
183
183
|
thread_id: conversation?.id,
|
|
184
|
-
assistant_id: this.assistantId.startsWith('asst') ? this.assistantId : null,
|
|
185
|
-
prompt_id: this.assistantId.startsWith('pmpt') ? this.assistantId : null,
|
|
186
184
|
code,
|
|
187
185
|
};
|
|
188
186
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
const { OpenAI } = require('openai');
|
|
2
2
|
|
|
3
|
+
const DEFAULT_MAX_RETRIES = parseInt(process.env.MAX_RETRIES || '10', 10);
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* Provider wrapper that targets the legacy Assistants (threads/runs) API surface.
|
|
5
7
|
* Consumers can continue using the existing helper methods while we gradually
|
|
@@ -256,7 +258,7 @@ class OpenAIAssistantsProvider {
|
|
|
256
258
|
return outputs;
|
|
257
259
|
}
|
|
258
260
|
|
|
259
|
-
async checkRunStatus(assistant, thread_id, run_id, retryCount = 0, maxRetries =
|
|
261
|
+
async checkRunStatus(assistant, thread_id, run_id, retryCount = 0, maxRetries = DEFAULT_MAX_RETRIES, actionHandled = false) {
|
|
260
262
|
try {
|
|
261
263
|
const run = await this.getRun({ threadId: thread_id, runId: run_id });
|
|
262
264
|
console.log(`Status: ${run.status} ${thread_id} ${run_id} (attempt ${retryCount + 1})`);
|
|
@@ -2,6 +2,7 @@ const { OpenAI } = require('openai');
|
|
|
2
2
|
|
|
3
3
|
const CONVERSATION_PREFIX = 'conv_';
|
|
4
4
|
const RESPONSE_PREFIX = 'resp_';
|
|
5
|
+
const DEFAULT_MAX_RETRIES = parseInt(process.env.MAX_RETRIES || '10', 10);
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Provider wrapper that targets the Conversations + Responses API surface.
|
|
@@ -21,7 +22,7 @@ class OpenAIResponsesProvider {
|
|
|
21
22
|
|
|
22
23
|
this.client = client || new OpenAI({ apiKey, organization });
|
|
23
24
|
this.defaults = {
|
|
24
|
-
responseModel: '
|
|
25
|
+
responseModel: 'gpt-5',
|
|
25
26
|
chatModel: 'gpt-4o-mini',
|
|
26
27
|
transcriptionModel: 'whisper-1',
|
|
27
28
|
reasoningEffort: 'medium',
|
|
@@ -137,6 +138,7 @@ class OpenAIResponsesProvider {
|
|
|
137
138
|
maxOutputTokens,
|
|
138
139
|
truncationStrategy,
|
|
139
140
|
tools = [],
|
|
141
|
+
model,
|
|
140
142
|
} = {}) {
|
|
141
143
|
try {
|
|
142
144
|
const id = this._ensurethreadId(threadId);
|
|
@@ -145,6 +147,7 @@ class OpenAIResponsesProvider {
|
|
|
145
147
|
const payload = this._cleanObject({
|
|
146
148
|
conversation: id,
|
|
147
149
|
prompt: { id: assistantId },
|
|
150
|
+
model: model || this.defaults.responseModel,
|
|
148
151
|
instructions: additionalInstructions || instructions,
|
|
149
152
|
input: [...messages, ...toolOutputs],
|
|
150
153
|
metadata,
|
|
@@ -289,7 +292,7 @@ class OpenAIResponsesProvider {
|
|
|
289
292
|
return outputs;
|
|
290
293
|
}
|
|
291
294
|
|
|
292
|
-
async checkRunStatus(assistant, thread_id, run_id, retryCount = 0, maxRetries =
|
|
295
|
+
async checkRunStatus(assistant, thread_id, run_id, retryCount = 0, maxRetries = DEFAULT_MAX_RETRIES, actionHandled = false) {
|
|
293
296
|
try {
|
|
294
297
|
let run = await this.getRun({ threadId: thread_id, runId: run_id });
|
|
295
298
|
console.log(`Status: ${run.status} ${thread_id} ${run_id} (attempt ${retryCount + 1})`);
|
|
@@ -13,6 +13,8 @@ const { processIndividualMessage, getLastMessages } = require('../helpers/assist
|
|
|
13
13
|
const { combineImagesToPDF, cleanupFiles } = require('../helpers/filesHelper.js');
|
|
14
14
|
const { delay } = require('../helpers/whatsappHelper.js');
|
|
15
15
|
|
|
16
|
+
const DEFAULT_MAX_RETRIES = parseInt(process.env.MAX_RETRIES || '30', 10);
|
|
17
|
+
|
|
16
18
|
let assistantConfig = null;
|
|
17
19
|
let assistantRegistry = {};
|
|
18
20
|
let customGetAssistantById = null;
|
|
@@ -52,7 +54,7 @@ const runAssistantAndWait = async ({
|
|
|
52
54
|
await Thread.updateOne(filter, { $set: { run_id: run.id } });
|
|
53
55
|
}
|
|
54
56
|
|
|
55
|
-
const maxRetries = polling?.maxRetries ??
|
|
57
|
+
const maxRetries = polling?.maxRetries ?? DEFAULT_MAX_RETRIES;
|
|
56
58
|
let completed = false;
|
|
57
59
|
|
|
58
60
|
try {
|
|
@@ -248,7 +250,7 @@ const addMsgAssistant = async (code, inMessages, reply = false) => {
|
|
|
248
250
|
|
|
249
251
|
let output, completed;
|
|
250
252
|
let retries = 0;
|
|
251
|
-
const maxRetries =
|
|
253
|
+
const maxRetries = DEFAULT_MAX_RETRIES;
|
|
252
254
|
const assistant = getAssistantById(thread.getAssistantId(), thread);
|
|
253
255
|
do {
|
|
254
256
|
({ output, completed } = await runAssistantAndWait({ thread, assistant }));
|
|
@@ -275,7 +277,7 @@ const addInsAssistant = async (code, instruction) => {
|
|
|
275
277
|
|
|
276
278
|
let output, completed;
|
|
277
279
|
let retries = 0;
|
|
278
|
-
const maxRetries =
|
|
280
|
+
const maxRetries = DEFAULT_MAX_RETRIES;
|
|
279
281
|
const assistant = getAssistantById(thread.getAssistantId(), thread);
|
|
280
282
|
do {
|
|
281
283
|
({ output, completed } = await runAssistantAndWait({
|
|
@@ -400,7 +402,7 @@ const replyAssistant = async function (code, message_ = null, thread_ = null, ru
|
|
|
400
402
|
|
|
401
403
|
let run, output, completed;
|
|
402
404
|
let retries = 0;
|
|
403
|
-
const maxRetries =
|
|
405
|
+
const maxRetries = DEFAULT_MAX_RETRIES;
|
|
404
406
|
do {
|
|
405
407
|
({ run, output, completed } = await runAssistantAndWait({
|
|
406
408
|
thread,
|