@xuda.io/ai_module 1.1.4366 → 1.1.4368
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.
- package/index.mjs +9 -5
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -5665,7 +5665,7 @@ export const create_account_profile_avatar = async function (req, job_id, header
|
|
|
5665
5665
|
req.is_profile_avatar = true;
|
|
5666
5666
|
req.account_obj = await db_module.get_couch_doc_native('xuda_accounts', uid);
|
|
5667
5667
|
|
|
5668
|
-
return await
|
|
5668
|
+
return await get_profile_avatar(req, job_id, headers);
|
|
5669
5669
|
} catch (err) {
|
|
5670
5670
|
return {
|
|
5671
5671
|
code: -25,
|
|
@@ -5674,7 +5674,7 @@ export const create_account_profile_avatar = async function (req, job_id, header
|
|
|
5674
5674
|
}
|
|
5675
5675
|
};
|
|
5676
5676
|
|
|
5677
|
-
export const
|
|
5677
|
+
export const get_profile_avatar = async function (req, job_id, headers) {
|
|
5678
5678
|
const tempDir = os.tmpdir();
|
|
5679
5679
|
const uniqueId = Date.now() + '_' + Math.random().toString(36).substring(7);
|
|
5680
5680
|
const tempOutputPath = path.join(tempDir, `output_${uniqueId}.png`);
|
|
@@ -6159,7 +6159,7 @@ export const modify_profile_avatar = async function (req, job_id, headers) {
|
|
|
6159
6159
|
}
|
|
6160
6160
|
|
|
6161
6161
|
let account_obj = await db_module.get_couch_doc_native('xuda_accounts', uid);
|
|
6162
|
-
const ret = await
|
|
6162
|
+
const ret = await get_profile_avatar({ prompt, url: account_obj.account_info?.profile_avatar, uid, account_obj, account_profile_info }, job_id, headers);
|
|
6163
6163
|
return ret;
|
|
6164
6164
|
} catch (err) {
|
|
6165
6165
|
return { code: -111, data: err.message };
|
|
@@ -6787,7 +6787,7 @@ export const get_profile_picture = async function (uid, account_type = 'business
|
|
|
6787
6787
|
.replace(/^_+|_+$/g, ''); // trim leading/trailing underscores
|
|
6788
6788
|
}
|
|
6789
6789
|
|
|
6790
|
-
let prompt, factual_prompt, originalname, factual_image_mode, imageBase64, image_blob_ret, file;
|
|
6790
|
+
let prompt, factual_prompt, originalname, factual_image_mode, imageBase64, image_blob_ret, file, profile_picture_source;
|
|
6791
6791
|
|
|
6792
6792
|
switch (account_type) {
|
|
6793
6793
|
case 'personal': {
|
|
@@ -6828,16 +6828,20 @@ export const get_profile_picture = async function (uid, account_type = 'business
|
|
|
6828
6828
|
// debugger;
|
|
6829
6829
|
try {
|
|
6830
6830
|
// first attempt
|
|
6831
|
+
profile_picture_source = 'internet search';
|
|
6831
6832
|
let url = await get_url();
|
|
6833
|
+
|
|
6832
6834
|
if (url.substr(0, 8) !== 'https://') {
|
|
6835
|
+
profile_picture_source = 'factual';
|
|
6833
6836
|
// second attempt
|
|
6834
6837
|
url = await get_url();
|
|
6835
6838
|
if (url.substr(0, 8) !== 'https://') {
|
|
6836
6839
|
factual_image_mode = true;
|
|
6840
|
+
profile_picture_source = 'factual';
|
|
6837
6841
|
}
|
|
6838
6842
|
} else {
|
|
6839
6843
|
// success
|
|
6840
|
-
|
|
6844
|
+
profile_picture_source = 'internet search';
|
|
6841
6845
|
try {
|
|
6842
6846
|
image_blob_ret = await get_image_blob_from_downloaded_image(url);
|
|
6843
6847
|
} catch (err) {
|