@xuda.io/ai_module 1.1.4340 → 1.1.4342

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.mjs +14 -17
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -6734,9 +6734,7 @@ const get_profile_image = async function (uid, account_type = 'business', name,
6734
6734
  .replace(/^_+|_+$/g, ''); // trim leading/trailing underscores
6735
6735
  }
6736
6736
 
6737
- const get_factual_image = function () {};
6738
-
6739
- let prompt, factual_prompt, originalname, factual_image_mode;
6737
+ let prompt, factual_prompt, originalname, factual_image_mode, imageBase64;
6740
6738
 
6741
6739
  switch (account_type) {
6742
6740
  case 'personal': {
@@ -6790,26 +6788,25 @@ const get_profile_image = async function (uid, account_type = 'business', name,
6790
6788
  file = await get_image_blob_from_downloaded_image(url);
6791
6789
  } catch (err) {
6792
6790
  // create factual image
6793
- imageBase64 = await create_image(uid, factual_prompt, undefined, undefined, 1, undefined, undefined, {}, account_profile_info);
6794
6791
  factual_image_mode = true;
6795
- // return console.error(err);
6796
6792
  }
6797
6793
  }
6798
- // const file = await get_image_blob_from_downloaded_image(url);
6799
- // const imageBase64 = Buffer.from(await file.image_blob.arrayBuffer()).toString('base64');
6800
- const model = 'chatgpt-image-latest';
6801
- const prompt = `
6794
+ if (factual_image_mode) {
6795
+ imageBase64 = await create_image(uid, factual_prompt, undefined, undefined, 1, undefined, undefined, {}, account_profile_info);
6796
+ } else {
6797
+ const model = 'chatgpt-image-latest';
6798
+ const prompt = `
6802
6799
  extract the logo from the image
6803
6800
  `;
6804
- const image_response = await client.images.edit({
6805
- model,
6806
- image: file.image_blob, //logo
6807
- prompt,
6808
- background: 'transparent',
6809
- });
6810
-
6811
- let imageBase64 = await normalizeBase64To1024(image_response.data[0].b64_json);
6801
+ const image_response = await client.images.edit({
6802
+ model,
6803
+ image: file.image_blob, //logo
6804
+ prompt,
6805
+ background: 'transparent',
6806
+ });
6812
6807
 
6808
+ imageBase64 = await normalizeBase64To1024(image_response.data[0].b64_json);
6809
+ }
6813
6810
  const outputBuffer = Buffer.from(imageBase64, 'base64');
6814
6811
  const outputPath = file.tempOutputPath;
6815
6812
  await fs.promises.writeFile(outputPath, outputBuffer);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.4340",
3
+ "version": "1.1.4342",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",