@peopl-health/nexus 5.72.5 → 5.72.6
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.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const { createLLMProvider } = require('../providers/createLLMProvider');
|
|
2
|
+
const { REQUEST_MAX_RETRIES, resolveRequestTimeoutMs } = require('../providers/AnthropicProvider');
|
|
2
3
|
const runtimeConfig = require('../../config/runtimeConfig');
|
|
3
4
|
|
|
4
5
|
const { logger } = require('../../utils/logger');
|
|
@@ -50,7 +51,7 @@ const getAnthropicClient = () => {
|
|
|
50
51
|
if (!apiKey) return null;
|
|
51
52
|
try {
|
|
52
53
|
const { Anthropic } = require('@anthropic-ai/sdk');
|
|
53
|
-
state.anthropicClient = new Anthropic({ apiKey });
|
|
54
|
+
state.anthropicClient = new Anthropic({ apiKey, timeout: resolveRequestTimeoutMs(), maxRetries: REQUEST_MAX_RETRIES });
|
|
54
55
|
logger.info('[llmConfig] Anthropic client initialised');
|
|
55
56
|
} catch (error) {
|
|
56
57
|
logger.warn('[llmConfig] Failed to initialise Anthropic client', { error: error?.message });
|
|
@@ -2,6 +2,7 @@ const fs = require('fs');
|
|
|
2
2
|
const path = require('path');
|
|
3
3
|
|
|
4
4
|
const llmConfig = require('../config/llmConfig.js');
|
|
5
|
+
const { resolveRequestTimeoutMs, structuredTimeoutMs } = require('../providers/AnthropicProvider');
|
|
5
6
|
|
|
6
7
|
const { composePrompt } = require('../services/promptComposerService');
|
|
7
8
|
|
|
@@ -30,6 +31,7 @@ const DISPLAYED_NUMBER = /^-?\d+(?:[.,]\d+)?$/;
|
|
|
30
31
|
|
|
31
32
|
const ANALYSIS_MODEL = 'claude-sonnet-5';
|
|
32
33
|
const MAX_ANALYSIS_TOKENS = 4096;
|
|
34
|
+
const IMAGE_MAX_RETRIES = 1;
|
|
33
35
|
|
|
34
36
|
const ANALYSIS_PROMPT = `Eres un oncólogo clínico con experiencia. Recibirás una imagen que un paciente envió por WhatsApp. Puede ser una receta, un resultado de laboratorio, un estudio de imagen, una nota clínica, la pantalla de un aparato de medición casero, la caja de un medicamento, o algo sin relación médica.
|
|
35
37
|
|
|
@@ -199,7 +201,7 @@ async function analyzeImage(imagePath, isSticker = false, contentType = null) {
|
|
|
199
201
|
{ type: 'image', source: { type: 'base64', media_type: mimeType, data: base64Image } },
|
|
200
202
|
{ type: 'text', text: prompt }
|
|
201
203
|
]}]
|
|
202
|
-
});
|
|
204
|
+
}, { timeout: structuredTimeoutMs(maxTokens, resolveRequestTimeoutMs()), maxRetries: IMAGE_MAX_RETRIES });
|
|
203
205
|
|
|
204
206
|
if (isSticker) {
|
|
205
207
|
const result = await createImageMessage('Describe the image in detail.', ANALYSIS_MODEL, MAX_ANALYSIS_TOKENS);
|