cencori 1.16.0 → 1.16.2

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.
Files changed (43) hide show
  1. package/dist/agents/index.d.mts +5 -0
  2. package/dist/agents/index.d.ts +5 -0
  3. package/dist/agents/index.js +9 -2
  4. package/dist/agents/index.js.map +1 -1
  5. package/dist/agents/index.mjs +9 -2
  6. package/dist/agents/index.mjs.map +1 -1
  7. package/dist/ai/index.d.mts +15 -2
  8. package/dist/ai/index.d.ts +15 -2
  9. package/dist/ai/index.js +69 -2
  10. package/dist/ai/index.js.map +1 -1
  11. package/dist/ai/index.mjs +69 -2
  12. package/dist/ai/index.mjs.map +1 -1
  13. package/dist/compute/index.d.mts +1 -1
  14. package/dist/compute/index.d.ts +1 -1
  15. package/dist/documents/index.d.mts +1 -1
  16. package/dist/documents/index.d.ts +1 -1
  17. package/dist/index.d.mts +2 -2
  18. package/dist/index.d.ts +2 -2
  19. package/dist/index.js +69 -2
  20. package/dist/index.js.map +1 -1
  21. package/dist/index.mjs +69 -2
  22. package/dist/index.mjs.map +1 -1
  23. package/dist/judgment/index.d.mts +1 -1
  24. package/dist/judgment/index.d.ts +1 -1
  25. package/dist/memory/index.d.mts +1 -1
  26. package/dist/memory/index.d.ts +1 -1
  27. package/dist/react/index.js.map +1 -1
  28. package/dist/react/index.mjs.map +1 -1
  29. package/dist/storage/index.d.mts +1 -1
  30. package/dist/storage/index.d.ts +1 -1
  31. package/dist/telemetry/index.d.mts +1 -1
  32. package/dist/telemetry/index.d.ts +1 -1
  33. package/dist/{types-D91o22Gb.d.mts → types-9nSEJEk2.d.mts} +90 -3
  34. package/dist/{types-D91o22Gb.d.ts → types-9nSEJEk2.d.ts} +90 -3
  35. package/dist/vision/index.d.mts +1 -1
  36. package/dist/vision/index.d.ts +1 -1
  37. package/dist/voice/index.d.mts +1 -1
  38. package/dist/voice/index.d.ts +1 -1
  39. package/dist/web/index.d.mts +1 -1
  40. package/dist/web/index.d.ts +1 -1
  41. package/dist/workflow/index.d.mts +1 -1
  42. package/dist/workflow/index.d.ts +1 -1
  43. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -339,6 +339,73 @@ var AINamespace = class {
339
339
  }
340
340
  };
341
341
  }
342
+ /**
343
+ * Check text or images for safety, fraud and scam signals.
344
+ * Covers OpenAI's moderation categories plus fraud/* (phishing, advance-fee,
345
+ * investment, giveaway, impersonation, real-money trading, off-platform
346
+ * payment and contact), cheating/exploit, hate/ethnic and child_safety/grooming,
347
+ * and any custom categories you describe. Only unclear items reach the paid
348
+ * model layer.
349
+ *
350
+ * @example
351
+ * const { results } = await cencori.ai.moderation({ input: 'Send 5k to my opay and get 50k back' });
352
+ * if (results[0].action === 'block') rejectMessage();
353
+ */
354
+ async moderation(request2) {
355
+ const response = await fetchWithRetry(`${this.config.baseUrl}/api/ai/moderation`, {
356
+ method: "POST",
357
+ headers: {
358
+ "CENCORI_API_KEY": this.config.apiKey,
359
+ "Content-Type": "application/json",
360
+ ...this.config.headers
361
+ },
362
+ body: JSON.stringify({
363
+ input: request2.input,
364
+ model: request2.model,
365
+ layers: request2.layers,
366
+ thresholds: request2.thresholds,
367
+ block_threshold: request2.blockThreshold,
368
+ escalate: request2.escalate,
369
+ llm_model: request2.llmModel,
370
+ custom_categories: request2.customCategories,
371
+ blocklist: request2.blocklist,
372
+ allowlist: request2.allowlist,
373
+ brand_names: request2.brandNames,
374
+ context: request2.context,
375
+ previous_messages: request2.previousMessages,
376
+ category_actions: request2.categoryActions
377
+ })
378
+ });
379
+ if (!response.ok) {
380
+ const errorData = await response.json().catch(() => ({ error: "Unknown error" }));
381
+ throwCencoriError(response, errorData);
382
+ }
383
+ const data = await response.json();
384
+ const results = data.results.map((r) => ({
385
+ flagged: r.flagged,
386
+ action: r.action,
387
+ categories: r.categories,
388
+ categoryScores: r.category_scores,
389
+ flaggedCategories: r.flagged_categories,
390
+ matches: r.matches,
391
+ layersApplied: r.layers_applied ?? []
392
+ }));
393
+ return {
394
+ id: data.id,
395
+ model: data.model,
396
+ flagged: results.some((r) => r.flagged),
397
+ results,
398
+ layers: data.layers,
399
+ usage: {
400
+ llmItems: data.usage?.llm_items ?? 0,
401
+ llmCachedItems: data.usage?.llm_cached_items ?? 0,
402
+ llmCalls: data.usage?.llm_calls ?? 0,
403
+ llmModel: data.usage?.llm_model ?? null,
404
+ costUsd: data.usage?.cost_usd ?? 0
405
+ },
406
+ ...data.errors ? { errors: data.errors } : {}
407
+ };
408
+ }
342
409
  /**
343
410
  * Generate structured output with JSON schema
344
411
  *
@@ -421,7 +488,7 @@ var AINamespace = class {
421
488
  * @example
422
489
  * const response = await cencori.ai.generateImage({
423
490
  * prompt: 'A futuristic city at sunset',
424
- * model: 'dall-e-3',
491
+ * model: 'gpt-image-1',
425
492
  * size: '1024x1024'
426
493
  * });
427
494
  * console.log(response.images[0].url);
@@ -436,7 +503,7 @@ var AINamespace = class {
436
503
  },
437
504
  body: JSON.stringify({
438
505
  prompt: request2.prompt,
439
- model: request2.model ?? "dall-e-3",
506
+ model: request2.model ?? "gpt-image-1",
440
507
  n: request2.n,
441
508
  size: request2.size,
442
509
  quality: request2.quality,