CognxSafeTrack commited on
Commit
184eeee
·
1 Parent(s): 255918d

fix: comprehensive vision hardening (loosen wordcount bypass + 60s timeout)

Browse files
apps/api/src/services/ai/openai-provider.ts CHANGED
@@ -21,7 +21,7 @@ export class OpenAIProvider implements LLMProvider {
21
  console.log('[OPENAI] Initializing SDK with custom fetch wrapper...');
22
  this.openai = new OpenAI({
23
  apiKey,
24
- timeout: 30_000, // 30s timeout for audio/STT
25
  maxRetries: 2,
26
  });
27
  }
@@ -30,7 +30,7 @@ export class OpenAIProvider implements LLMProvider {
30
  console.log(`[OPENAI] Generating structured data... (Vision: ${!!imageUrl})`);
31
 
32
  const timeout = new Promise<never>((_, reject) =>
33
- setTimeout(() => reject(new Error('OpenAI timeout after 30s')), 30_000)
34
  );
35
 
36
  const responseFormat = zodResponseFormat(schema as z.ZodTypeAny, 'output_schema');
 
21
  console.log('[OPENAI] Initializing SDK with custom fetch wrapper...');
22
  this.openai = new OpenAI({
23
  apiKey,
24
+ timeout: 60_000, // 60s timeout for Vision/Audio
25
  maxRetries: 2,
26
  });
27
  }
 
30
  console.log(`[OPENAI] Generating structured data... (Vision: ${!!imageUrl})`);
31
 
32
  const timeout = new Promise<never>((_, reject) =>
33
+ setTimeout(() => reject(new Error('OpenAI timeout after 60s')), 60_000)
34
  );
35
 
36
  const responseFormat = zodResponseFormat(schema as z.ZodTypeAny, 'output_schema');
apps/whatsapp-worker/src/services/whatsapp-logic.ts CHANGED
@@ -319,7 +319,7 @@ export class WhatsAppLogic {
319
  ['whatsapp', 'boutique', 'digital', 'physique', 'tel', 'e-commerce'].includes(normalizedText)
320
  );
321
 
322
- const isVisionDay = !!imageUrl && (activeEnrollment.currentDay === 8 || activeEnrollment.currentDay === 11);
323
  const shouldBypassGuardrail = isButtonChoice || isDay7Special || isVisionDay;
324
 
325
  if (isVisionDay) {
 
319
  ['whatsapp', 'boutique', 'digital', 'physique', 'tel', 'e-commerce'].includes(normalizedText)
320
  );
321
 
322
+ const isVisionDay = !!imageUrl; // Any image should bypass wordcount to be analyzed
323
  const shouldBypassGuardrail = isButtonChoice || isDay7Special || isVisionDay;
324
 
325
  if (isVisionDay) {