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.
- package/dist/agents/index.d.mts +5 -0
- package/dist/agents/index.d.ts +5 -0
- package/dist/agents/index.js +9 -2
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/index.mjs +9 -2
- package/dist/agents/index.mjs.map +1 -1
- package/dist/ai/index.d.mts +15 -2
- package/dist/ai/index.d.ts +15 -2
- package/dist/ai/index.js +69 -2
- package/dist/ai/index.js.map +1 -1
- package/dist/ai/index.mjs +69 -2
- package/dist/ai/index.mjs.map +1 -1
- package/dist/compute/index.d.mts +1 -1
- package/dist/compute/index.d.ts +1 -1
- package/dist/documents/index.d.mts +1 -1
- package/dist/documents/index.d.ts +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +69 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +69 -2
- package/dist/index.mjs.map +1 -1
- package/dist/judgment/index.d.mts +1 -1
- package/dist/judgment/index.d.ts +1 -1
- package/dist/memory/index.d.mts +1 -1
- package/dist/memory/index.d.ts +1 -1
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs.map +1 -1
- package/dist/storage/index.d.mts +1 -1
- package/dist/storage/index.d.ts +1 -1
- package/dist/telemetry/index.d.mts +1 -1
- package/dist/telemetry/index.d.ts +1 -1
- package/dist/{types-D91o22Gb.d.mts → types-9nSEJEk2.d.mts} +90 -3
- package/dist/{types-D91o22Gb.d.ts → types-9nSEJEk2.d.ts} +90 -3
- package/dist/vision/index.d.mts +1 -1
- package/dist/vision/index.d.ts +1 -1
- package/dist/voice/index.d.mts +1 -1
- package/dist/voice/index.d.ts +1 -1
- package/dist/web/index.d.mts +1 -1
- package/dist/web/index.d.ts +1 -1
- package/dist/workflow/index.d.mts +1 -1
- package/dist/workflow/index.d.ts +1 -1
- 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: '
|
|
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 ?? "
|
|
506
|
+
model: request2.model ?? "gpt-image-1",
|
|
440
507
|
n: request2.n,
|
|
441
508
|
size: request2.size,
|
|
442
509
|
quality: request2.quality,
|