@picsart/ai-sdk 6.21.0 → 6.21.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 (2) hide show
  1. package/index.js +18 -4
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -8104,7 +8104,6 @@ var { MODELS: MODELS26 } = defineModels("ideogram", [
8104
8104
  id: "ideogram-4-5",
8105
8105
  name: "Ideogram 4.5",
8106
8106
  addedAt: "2026-09-28",
8107
- release: "preview",
8108
8107
  workflow: "ideogram/v4.5/generate",
8109
8108
  estimatedTime: 30,
8110
8109
  mode: "image",
@@ -8129,7 +8128,6 @@ var { MODELS: MODELS26 } = defineModels("ideogram", [
8129
8128
  id: "ideogram-4-5-precise-edit",
8130
8129
  name: "Ideogram 4.5 Precise Edit",
8131
8130
  addedAt: "2026-09-28",
8132
- release: "preview",
8133
8131
  workflow: "ideogram/v4.5/precise-edit",
8134
8132
  estimatedTime: 40,
8135
8133
  mode: "image",
@@ -12342,6 +12340,7 @@ function parseTextResult(completed, model) {
12342
12340
 
12343
12341
  // src/core/limits.ts
12344
12342
  var MAX_DRIVE_PROMPT_LENGTH = 18e3;
12343
+ var MAX_DRIVE_ATTRIBUTE_LENGTH = 2e4;
12345
12344
 
12346
12345
  // src/client/drive.ts
12347
12346
  var USER_REACTION_ATTR = "userReaction";
@@ -12497,7 +12496,7 @@ function parseJsonAttr(raw) {
12497
12496
  var asString = (v) => typeof v === "string" && v.trim() ? v : void 0;
12498
12497
  var asStringArray = (v) => Array.isArray(v) && v.length && v.every((x) => typeof x === "string") ? v : void 0;
12499
12498
  function toSdkPayload(params2) {
12500
- const p2 = { prompt: String(params2.prompt ?? "").slice(0, MAX_DRIVE_PROMPT_LENGTH) };
12499
+ const p2 = { prompt: cutPrompt(String(params2.prompt ?? ""), MAX_DRIVE_PROMPT_LENGTH) };
12501
12500
  for (const [key, value] of Object.entries(params2)) {
12502
12501
  if (key === "prompt") continue;
12503
12502
  if (value === void 0 || value === null || value === "") continue;
@@ -12505,10 +12504,25 @@ function toSdkPayload(params2) {
12505
12504
  }
12506
12505
  return p2;
12507
12506
  }
12507
+ function cutPrompt(prompt, max) {
12508
+ if (prompt.length <= max) return prompt;
12509
+ const code = prompt.charCodeAt(max - 1);
12510
+ return prompt.slice(0, code >= 55296 && code <= 56319 ? max - 1 : max);
12511
+ }
12512
+ function serializeSdkPayload(params2) {
12513
+ const payload = toSdkPayload(params2);
12514
+ let prompt = payload.prompt;
12515
+ for (; ; ) {
12516
+ const serialized = JSON.stringify({ ...payload, prompt });
12517
+ const excess = serialized.length - MAX_DRIVE_ATTRIBUTE_LENGTH;
12518
+ if (excess <= 0 || prompt.length === 0) return serialized;
12519
+ prompt = cutPrompt(prompt, Math.max(0, prompt.length - excess));
12520
+ }
12521
+ }
12508
12522
  function buildGenerationAttributes(input) {
12509
12523
  const attrs = {
12510
12524
  model: input.modelId,
12511
- aiSDKPayload: JSON.stringify(toSdkPayload(input.params))
12525
+ aiSDKPayload: serializeSdkPayload(input.params)
12512
12526
  };
12513
12527
  if (input.app) {
12514
12528
  attrs.appId = input.app.id;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@picsart/ai-sdk",
3
- "version": "6.21.0",
3
+ "version": "6.21.2",
4
4
  "type": "module",
5
5
  "description": "Type-safe SDK for 100+ AI models — image, video, audio, and text generation with Picsart",
6
6
  "license": "MIT",