@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: 600,
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: instructions || additionalInstructions,
304
- max_output_tokens: maxOutputTokens ?? this.defaults.maxOutputTokens,
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
- // Add line breaks after dash items (bullet points)
16
- formatted = formatted.replace(/(\.\s*-\s+)/g, '.\n- ');
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
- // Add line breaks after semicolons when they separate items
20
- formatted = formatted.replace(/;\s*-\s+/g, ';\n- ');
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
- // Add line breaks after periods that end sentences before dashes
23
- formatted = formatted.replace(/(\.\s+)(-\s+)/g, '$1\n$2');
22
+ // Convert markdown * bullets to WhatsApp - bullets (avoid conflict with *bold*)
23
+ formatted = formatted.replace(/^\*\s+/gm, '- '); // * bullet → - bullet
24
24
 
25
- // Clean up multiple consecutive line breaks
26
- formatted = formatted.replace(/\n{2,}/g, '\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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peopl-health/nexus",
3
- "version": "3.2.7",
3
+ "version": "3.2.8",
4
4
  "description": "Core messaging and assistant library for WhatsApp communication platforms",
5
5
  "keywords": [
6
6
  "whatsapp",