@xuda.io/ai_module 1.1.4385 → 1.1.4386

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 +11 -34
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -5704,7 +5704,7 @@ export const get_profile_avatar = async function (profile_picture, uid, prompt,
5704
5704
  response_format: z.object({
5705
5705
  is_real_person_in_picture: z.boolean().describe('if a postrate of real person in the picture return true otherwise return false'),
5706
5706
  }),
5707
- metadata: { account_id: _id, func: 'detect_real_person_in_image' },
5707
+ metadata: { _id, func: 'detect_real_person_in_image' },
5708
5708
  account_profile_info,
5709
5709
  });
5710
5710
 
@@ -5864,7 +5864,7 @@ export const get_profile_avatar = async function (profile_picture, uid, prompt,
5864
5864
  console.log('Success! Saved →', outputPath);
5865
5865
 
5866
5866
  const ext = 'png';
5867
- const originalname = `avatar_${email || _id}.${ext}`;
5867
+ const originalname = `avatar_${email || _id || name}.${ext}`;
5868
5868
 
5869
5869
  const file_obj = {
5870
5870
  originalname,
@@ -5876,30 +5876,7 @@ export const get_profile_avatar = async function (profile_picture, uid, prompt,
5876
5876
  drive_ret.avatar_source = avatar_source;
5877
5877
 
5878
5878
  return drive_ret;
5879
- // if (drive_ret.code > 0) {
5880
- // // if (!is_profile_avatar) {
5881
- // // let db_doc = await db_module.get_couch_doc_native('xuda_accounts', account_obj._id);
5882
- // // db_doc.account_info.profile_avatar = drive_ret.data.file_url;
5883
- // // db_doc.account_info.profile_avatar_obj == drive_ret.data;
5884
- // // db_doc.account_info.avatar_source = avatar_source;
5885
- // // db_doc.image_request_ts = Date.now();
5886
- // // const save_ret = await db_module.save_couch_doc_native('xuda_accounts', db_doc);
5887
- // // console.log(save_ret);
5888
- // // await update_profile_avatar_status(uid, 3);
5889
- // // return save_ret;
5890
- // // } else {
5891
- // // return drive_ret;
5892
- // // }
5893
-
5894
- // // account_module.update_contacts_with_account_changes(db_doc._id, ['profile_avatar']);
5895
- // return drive_ret;
5896
- // } else {
5897
- // throw new Error(drive_ret.data);
5898
- // }
5899
5879
  } catch (error) {
5900
- // if (!is_profile_avatar) {
5901
- // await update_profile_avatar_status(uid, 1);
5902
- // }
5903
5880
  console.error('Error:', error.message);
5904
5881
  if (error.response?.data) {
5905
5882
  console.error('OpenAI API response:', error.response.data);
@@ -6641,20 +6618,20 @@ export const is_business_contact = async function (uid, email, name, subject, bo
6641
6618
  } catch (error) {}
6642
6619
  };
6643
6620
 
6621
+ function normalizeFilename(name) {
6622
+ return name
6623
+ .toLowerCase() // lowercase
6624
+ .replace(/\s+/g, '_') // replace all spaces with single underscore
6625
+ .replace(/[^a-z0-9._-]/g, '') // remove anything that's not letter, number, dot, underscore, or hyphen
6626
+ .replace(/_+/g, '_') // collapse multiple underscores
6627
+ .replace(/^_+|_+$/g, ''); // trim leading/trailing underscores
6628
+ }
6629
+
6644
6630
  export const get_profile_picture = async function (uid, account_type = 'business', name, metadata = {}, account_profile_info, job_id, headers) {
6645
6631
  const tempDir = os.tmpdir();
6646
6632
  const uniqueId = Date.now() + '_' + Math.random().toString(36).substring(7);
6647
6633
  const tempOutputPath = path.join(tempDir, `output_${uniqueId}.png`);
6648
6634
 
6649
- function normalizeFilename(name) {
6650
- return name
6651
- .toLowerCase() // lowercase
6652
- .replace(/\s+/g, '_') // replace all spaces with single underscore
6653
- .replace(/[^a-z0-9._-]/g, '') // remove anything that's not letter, number, dot, underscore, or hyphen
6654
- .replace(/_+/g, '_') // collapse multiple underscores
6655
- .replace(/^_+|_+$/g, ''); // trim leading/trailing underscores
6656
- }
6657
-
6658
6635
  let prompt, factual_prompt, originalname, factual_image_mode, imageBase64, image_blob_ret, file, profile_picture_source;
6659
6636
 
6660
6637
  switch (account_type) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.4385",
3
+ "version": "1.1.4386",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",