@peopl-health/nexus 3.2.6 → 3.2.8
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.
|
@@ -37,7 +37,9 @@ class OpenAIResponsesProvider {
|
|
|
37
37
|
responseModel: 'gpt-5',
|
|
38
38
|
chatModel: 'gpt-4o-mini',
|
|
39
39
|
transcriptionModel: 'whisper-1',
|
|
40
|
-
|
|
40
|
+
temperature: 0.7,
|
|
41
|
+
maxOutputTokens: 400,
|
|
42
|
+
brevityInstruction: 'Responde de forma breve y concisa en formato de texto para whatsapp, máximo 100 palabras.',
|
|
41
43
|
...defaultModels,
|
|
42
44
|
};
|
|
43
45
|
|
|
@@ -282,7 +284,7 @@ class OpenAIResponsesProvider {
|
|
|
282
284
|
promptVersion = null,
|
|
283
285
|
promptVariables = null
|
|
284
286
|
} = {}) {
|
|
285
|
-
try {
|
|
287
|
+
try {
|
|
286
288
|
let input = context || this._convertItemsToApiFormat(additionalMessages);
|
|
287
289
|
let allToolsExecuted = [];
|
|
288
290
|
let totalRetries = 0;
|
|
@@ -294,15 +296,21 @@ class OpenAIResponsesProvider {
|
|
|
294
296
|
if (promptVersion) promptConfig.version = String(promptVersion);
|
|
295
297
|
logger.info('[OpenAIResponsesProvider] Prompt config', { promptConfig });
|
|
296
298
|
|
|
299
|
+
const baseInstructions = instructions || additionalInstructions || '';
|
|
300
|
+
const fullInstructions = baseInstructions
|
|
301
|
+
? `${baseInstructions}\n\n${this.defaults.brevityInstruction}`
|
|
302
|
+
: this.defaults.brevityInstruction;
|
|
303
|
+
|
|
297
304
|
const makeAPICall = (inputData) => retryWithBackoff(() =>
|
|
298
305
|
this.client.responses.create({
|
|
299
306
|
prompt: promptConfig,
|
|
300
307
|
input: inputData,
|
|
301
|
-
instructions:
|
|
302
|
-
|
|
308
|
+
instructions: fullInstructions,
|
|
309
|
+
store: false
|
|
303
310
|
}), { providerName: PROVIDER_NAME });
|
|
304
311
|
|
|
305
312
|
const { result: response, retries } = await makeAPICall(input);
|
|
313
|
+
logger.info('[OpenAIResponsesProvider] Run response', { response });
|
|
306
314
|
totalRetries += retries;
|
|
307
315
|
let finalResponse = response;
|
|
308
316
|
|
|
@@ -12,22 +12,18 @@ function formatForWhatsApp(text) {
|
|
|
12
12
|
|
|
13
13
|
let formatted = text;
|
|
14
14
|
|
|
15
|
-
//
|
|
16
|
-
formatted = formatted.replace(/
|
|
17
|
-
formatted = formatted.replace(/(:)\s*(-\s+)/g, '$1\n- ');
|
|
15
|
+
// Normalize line endings (CRLF → LF)
|
|
16
|
+
formatted = formatted.replace(/\r\n/g, '\n');
|
|
18
17
|
|
|
19
|
-
//
|
|
20
|
-
formatted = formatted.replace(
|
|
18
|
+
// Convert markdown to WhatsApp format
|
|
19
|
+
formatted = formatted.replace(/\*\*(.+?)\*\*/g, '*$1*'); // **bold** → *bold*
|
|
20
|
+
formatted = formatted.replace(/^#{1,6}\s*(.+)$/gm, '*$1*'); // # Header → *Header*
|
|
21
21
|
|
|
22
|
-
//
|
|
23
|
-
formatted = formatted.replace(
|
|
22
|
+
// Convert markdown * bullets to WhatsApp - bullets (avoid conflict with *bold*)
|
|
23
|
+
formatted = formatted.replace(/^\*\s+/gm, '- '); // * bullet → - bullet
|
|
24
24
|
|
|
25
|
-
//
|
|
26
|
-
formatted = formatted.replace(
|
|
27
|
-
formatted = formatted.replace(/(\n|^)\s*-\s+/g, '$1• ');
|
|
28
|
-
|
|
29
|
-
// Clean up multiple consecutive line breaks
|
|
30
|
-
formatted = formatted.replace(/\n{3,}/g, '\n\n');
|
|
25
|
+
// Collapse multiple line breaks or blank lines to single break
|
|
26
|
+
formatted = formatted.replace(/\n\s*\n/g, '\n');
|
|
31
27
|
|
|
32
28
|
return formatted.trim();
|
|
33
29
|
}
|