@2515097216/jimeng-free-api 0.8.11 → 0.8.12

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.
@@ -2406,7 +2406,7 @@ async function generateImageComposition(_model, prompt, imageUrls, {
2406
2406
  submit_id: submitId,
2407
2407
  metrics_extra: JSON.stringify({
2408
2408
  promptSource: "custom",
2409
- generateCount: finalTargetImageCount,
2409
+ generateCount: 1,
2410
2410
  enterFrom: "click",
2411
2411
  sceneOptions: JSON.stringify([sceneOption]),
2412
2412
  generateId: submitId,
@@ -2643,12 +2643,12 @@ async function generateMultiImages(_model, prompt, {
2643
2643
  const model = getModel(_model);
2644
2644
  const resolutionResult = resolveResolution(resolution, ratio);
2645
2645
  const { width, height, imageRatio, resolutionType } = resolutionResult;
2646
- const finalTargetImageCount2 = _13.clamp(
2646
+ const finalTargetImageCount = _13.clamp(
2647
2647
  targetImageCount ?? (prompt.match(/(\d+)张/) ? parseInt(prompt.match(/(\d+)张/)[1]) : 4),
2648
2648
  1,
2649
2649
  10
2650
2650
  );
2651
- logger_default.info(`\u4F7F\u7528 ${_model} \u591A\u56FE\u751F\u6210: ${finalTargetImageCount2}\u5F20\u56FE\u7247 ${width}x${height} (${ratio}@${resolution}) \u7CBE\u7EC6\u5EA6: ${sampleStrength}`);
2651
+ logger_default.info(`\u4F7F\u7528 ${_model} \u591A\u56FE\u751F\u6210: ${finalTargetImageCount}\u5F20\u56FE\u7247 ${width}x${height} (${ratio}@${resolution}) \u7CBE\u7EC6\u5EA6: ${sampleStrength}`);
2652
2652
  const componentId = util_default.uuid();
2653
2653
  const submitId = util_default.uuid();
2654
2654
  const sceneOption = {
@@ -2737,7 +2737,7 @@ async function generateMultiImages(_model, prompt, {
2737
2737
  gen_option: {
2738
2738
  type: "",
2739
2739
  id: util_default.uuid(),
2740
- generate_all: finalTargetImageCount2 > 1
2740
+ generate_all: finalTargetImageCount > 1
2741
2741
  }
2742
2742
  }
2743
2743
  }
@@ -2753,7 +2753,7 @@ async function generateMultiImages(_model, prompt, {
2753
2753
  const historyId = aigc_data == null ? void 0 : aigc_data.history_record_id;
2754
2754
  if (!historyId)
2755
2755
  throw new APIException(exceptions_default.API_IMAGE_GENERATION_FAILED, "\u8BB0\u5F55ID\u4E0D\u5B58\u5728");
2756
- logger_default.info(`\u591A\u56FE\u751F\u6210\u4EFB\u52A1\u5DF2\u63D0\u4EA4\uFF0Csubmit_id: ${submitId}, history_id: ${historyId}\uFF0C\u7B49\u5F85\u751F\u6210 ${finalTargetImageCount2} \u5F20\u56FE\u7247...`);
2756
+ logger_default.info(`\u591A\u56FE\u751F\u6210\u4EFB\u52A1\u5DF2\u63D0\u4EA4\uFF0Csubmit_id: ${submitId}, history_id: ${historyId}\uFF0C\u7B49\u5F85\u751F\u6210 ${finalTargetImageCount} \u5F20\u56FE\u7247...`);
2757
2757
  let status = 20, failCode, item_list = [];
2758
2758
  let pollCount = 0;
2759
2759
  let missingRecordCount = 0;
@@ -2762,7 +2762,7 @@ async function generateMultiImages(_model, prompt, {
2762
2762
  await new Promise((resolve) => setTimeout(resolve, 1e3));
2763
2763
  pollCount++;
2764
2764
  if (pollCount % 30 === 0) {
2765
- logger_default.info(`\u591A\u56FE\u751F\u6210\u8FDB\u5EA6: \u7B2C ${pollCount} \u6B21\u8F6E\u8BE2 (history_id: ${historyId})\uFF0C\u5F53\u524D\u72B6\u6001: ${status}\uFF0C\u5DF2\u751F\u6210: ${item_list.length}/${finalTargetImageCount2} \u5F20\u56FE\u7247...`);
2765
+ logger_default.info(`\u591A\u56FE\u751F\u6210\u8FDB\u5EA6: \u7B2C ${pollCount} \u6B21\u8F6E\u8BE2 (history_id: ${historyId})\uFF0C\u5F53\u524D\u72B6\u6001: ${status}\uFF0C\u5DF2\u751F\u6210: ${item_list.length}/${finalTargetImageCount} \u5F20\u56FE\u7247...`);
2766
2766
  }
2767
2767
  const result = await request("post", "/mweb/v1/get_history_by_ids", refreshToken, {
2768
2768
  data: {
@@ -2854,15 +2854,15 @@ async function generateMultiImages(_model, prompt, {
2854
2854
  status = result[historyId].status;
2855
2855
  failCode = result[historyId].fail_code;
2856
2856
  item_list = result[historyId].item_list || [];
2857
- if (item_list.length >= finalTargetImageCount2) {
2857
+ if (item_list.length >= finalTargetImageCount) {
2858
2858
  logger_default.info(`\u591A\u56FE\u751F\u6210\u5B8C\u6210: \u72B6\u6001=${status}, \u5DF2\u751F\u6210 ${item_list.length} \u5F20\u56FE\u7247`);
2859
2859
  break;
2860
2860
  }
2861
2861
  if (pollCount % 60 === 0) {
2862
2862
  logger_default.info(`jimeng-4.0 \u8BE6\u7EC6\u72B6\u6001: status=${status}, item_list.length=${item_list.length}, failCode=${failCode || "none"}`);
2863
2863
  }
2864
- if (status === 10 && item_list.length < finalTargetImageCount2 && pollCount % 30 === 0) {
2865
- logger_default.info(`jimeng-4.0 \u72B6\u6001\u5DF2\u5B8C\u6210\u4F46\u56FE\u7247\u6570\u91CF\u4E0D\u8DB3: \u72B6\u6001=${status}, \u5DF2\u751F\u6210 ${item_list.length}/${finalTargetImageCount2} \u5F20\u56FE\u7247\uFF0C\u7EE7\u7EED\u7B49\u5F85...`);
2864
+ if (status === 10 && item_list.length < finalTargetImageCount && pollCount % 30 === 0) {
2865
+ logger_default.info(`jimeng-4.0 \u72B6\u6001\u5DF2\u5B8C\u6210\u4F46\u56FE\u7247\u6570\u91CF\u4E0D\u8DB3: \u72B6\u6001=${status}, \u5DF2\u751F\u6210 ${item_list.length}/${finalTargetImageCount} \u5F20\u56FE\u7247\uFF0C\u7EE7\u7EED\u7B49\u5F85...`);
2866
2866
  }
2867
2867
  }
2868
2868
  if (pollCount >= maxPollCount) {
@@ -2879,7 +2879,7 @@ async function generateMultiImages(_model, prompt, {
2879
2879
  if (!((_c = (_b = (_a = item == null ? void 0 : item.image) == null ? void 0 : _a.large_images) == null ? void 0 : _b[0]) == null ? void 0 : _c.image_url))
2880
2880
  return ((_d = item == null ? void 0 : item.common_attr) == null ? void 0 : _d.cover_url) || null;
2881
2881
  return item.image.large_images[0].image_url;
2882
- }).filter((url) => url !== null).slice(0, finalTargetImageCount2);
2882
+ }).filter((url) => url !== null).slice(0, finalTargetImageCount);
2883
2883
  logger_default.info(`\u591A\u56FE\u751F\u6210\u7ED3\u679C: \u6210\u529F\u751F\u6210 ${imageUrls.length} \u5F20\u56FE\u7247`);
2884
2884
  return imageUrls;
2885
2885
  }
@@ -3186,6 +3186,13 @@ function buildPublicBaseUrl(headers = {}) {
3186
3186
  return `${protocol}://${host}${normalizePrefix(config_default.service.urlPrefix)}`;
3187
3187
  }
3188
3188
  async function saveRemoteAssetToLocalUrl(remoteUrl, assetType = "images", publicBaseUrl) {
3189
+ const { relativePath } = await saveRemoteAssetToLocalPath(remoteUrl, assetType);
3190
+ const baseUrl = publicBaseUrl || `${config_default.service.publicDirUrl.replace(/\/public$/, "")}${normalizePrefix(config_default.service.urlPrefix)}`;
3191
+ const localUrl = `${baseUrl}/public/${relativePath}`;
3192
+ logger_default.info(`asset localized: ${remoteUrl} -> ${localUrl}`);
3193
+ return localUrl;
3194
+ }
3195
+ async function saveRemoteAssetToLocalPath(remoteUrl, assetType = "images") {
3189
3196
  const response = await axios3.get(remoteUrl, {
3190
3197
  responseType: "arraybuffer",
3191
3198
  timeout: 12e4
@@ -3200,14 +3207,14 @@ async function saveRemoteAssetToLocalUrl(remoteUrl, assetType = "images", public
3200
3207
  const outputPath = path6.join(config_default.system.publicDirPath, ...relativePath.split("/"));
3201
3208
  await fs6.ensureDir(path6.dirname(outputPath));
3202
3209
  await fs6.writeFile(outputPath, response.data);
3203
- const baseUrl = publicBaseUrl || `${config_default.service.publicDirUrl.replace(/\/public$/, "")}${normalizePrefix(config_default.service.urlPrefix)}`;
3204
- const localUrl = `${baseUrl}/public/${relativePath}`;
3205
- logger_default.info(`asset localized: ${remoteUrl} -> ${localUrl}`);
3206
- return localUrl;
3210
+ return { outputPath, relativePath };
3207
3211
  }
3208
3212
  async function saveRemoteAssetsToLocalUrls(remoteUrls, assetType = "images", publicBaseUrl) {
3209
3213
  return Promise.all(remoteUrls.map((url) => saveRemoteAssetToLocalUrl(url, assetType, publicBaseUrl)));
3210
3214
  }
3215
+ async function saveRemoteAssetsToLocalPaths(remoteUrls, assetType = "images") {
3216
+ return Promise.all(remoteUrls.map((url) => saveRemoteAssetToLocalPath(url, assetType)));
3217
+ }
3211
3218
 
3212
3219
  // src/api/routes/images.ts
3213
3220
  var images_default = {
@@ -5721,9 +5728,11 @@ export {
5721
5728
  DEFAULT_MODEL,
5722
5729
  generateImageComposition,
5723
5730
  generateImages,
5731
+ saveRemoteAssetToLocalPath,
5732
+ saveRemoteAssetsToLocalPaths,
5724
5733
  DEFAULT_MODEL2,
5725
5734
  generateVideo,
5726
5735
  generateSeedanceVideo,
5727
5736
  routes_default
5728
5737
  };
5729
- //# sourceMappingURL=chunk-YJIZUPUG.js.map
5738
+ //# sourceMappingURL=chunk-FKUVCAUE.js.map