@peopl-health/nexus 3.2.7 → 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,9 +37,9 @@ class OpenAIResponsesProvider {
|
|
|
37
37
|
responseModel: 'gpt-5',
|
|
38
38
|
chatModel: 'gpt-4o-mini',
|
|
39
39
|
transcriptionModel: 'whisper-1',
|
|
40
|
-
reasoningEffort: 'low',
|
|
41
40
|
temperature: 0.7,
|
|
42
|
-
maxOutputTokens:
|
|
41
|
+
maxOutputTokens: 400,
|
|
42
|
+
brevityInstruction: 'Responde de forma breve y concisa en formato de texto para whatsapp, máximo 100 palabras.',
|
|
43
43
|
...defaultModels,
|
|
44
44
|
};
|
|
45
45
|
|
|
@@ -284,7 +284,7 @@ class OpenAIResponsesProvider {
|
|
|
284
284
|
promptVersion = null,
|
|
285
285
|
promptVariables = null
|
|
286
286
|
} = {}) {
|
|
287
|
-
try {
|
|
287
|
+
try {
|
|
288
288
|
let input = context || this._convertItemsToApiFormat(additionalMessages);
|
|
289
289
|
let allToolsExecuted = [];
|
|
290
290
|
let totalRetries = 0;
|
|
@@ -296,13 +296,17 @@ class OpenAIResponsesProvider {
|
|
|
296
296
|
if (promptVersion) promptConfig.version = String(promptVersion);
|
|
297
297
|
logger.info('[OpenAIResponsesProvider] Prompt config', { promptConfig });
|
|
298
298
|
|
|
299
|
+
const baseInstructions = instructions || additionalInstructions || '';
|
|
300
|
+
const fullInstructions = baseInstructions
|
|
301
|
+
? `${baseInstructions}\n\n${this.defaults.brevityInstruction}`
|
|
302
|
+
: this.defaults.brevityInstruction;
|
|
303
|
+
|
|
299
304
|
const makeAPICall = (inputData) => retryWithBackoff(() =>
|
|
300
305
|
this.client.responses.create({
|
|
301
306
|
prompt: promptConfig,
|
|
302
307
|
input: inputData,
|
|
303
|
-
instructions:
|
|
304
|
-
|
|
305
|
-
...(topP !== undefined && { top_p: topP }),
|
|
308
|
+
instructions: fullInstructions,
|
|
309
|
+
store: false
|
|
306
310
|
}), { providerName: PROVIDER_NAME });
|
|
307
311
|
|
|
308
312
|
const { result: response, retries } = await makeAPICall(input);
|
|
@@ -12,18 +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(/\n
|
|
25
|
+
// Collapse multiple line breaks or blank lines to single break
|
|
26
|
+
formatted = formatted.replace(/\n\s*\n/g, '\n');
|
|
27
27
|
|
|
28
28
|
return formatted.trim();
|
|
29
29
|
}
|