@xuda.io/ai_module 1.1.4340 → 1.1.4341

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