@xuda.io/ai_module 1.1.4774 → 1.1.4776

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 +40 -38
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -7036,54 +7036,56 @@ export const get_profile_picture = async function (uid, account_type = 'business
7036
7036
  // debugger;
7037
7037
  try {
7038
7038
  url = await getUserPhotoByEmail(email);
7039
-
7040
- // first attempt
7041
- if (account_type === 'business') {
7042
- url = await get_url();
7043
-
7044
- if (url.substr(0, 8) !== 'https://') {
7045
- profile_picture_source = 'factual';
7046
- // second attempt
7039
+ profile_picture_source = 'google';
7040
+ if (!url) {
7041
+ // first attempt
7042
+ if (account_type === 'business') {
7047
7043
  url = await get_url();
7044
+
7048
7045
  if (url.substr(0, 8) !== 'https://') {
7049
- factual_image_mode = true;
7050
7046
  profile_picture_source = 'factual';
7051
- }
7052
- } else {
7053
- // success
7054
- profile_picture_source = 'internet search';
7055
- try {
7056
- image_blob_ret = await get_image_blob_from_downloaded_image(url);
7057
- } catch (err) {
7058
- if (!err.message.includes('Failed to fetch image URL')) {
7059
- console.error(err);
7060
- return '';
7047
+ // second attempt
7048
+ url = await get_url();
7049
+ if (url.substr(0, 8) !== 'https://') {
7050
+ factual_image_mode = true;
7051
+ profile_picture_source = 'factual';
7052
+ }
7053
+ } else {
7054
+ // success
7055
+ profile_picture_source = 'internet search';
7056
+ try {
7057
+ image_blob_ret = await get_image_blob_from_downloaded_image(url);
7058
+ } catch (err) {
7059
+ if (!err.message.includes('Failed to fetch image URL')) {
7060
+ console.error(err);
7061
+ return '';
7062
+ }
7063
+ profile_picture_source = 'factual';
7064
+ factual_image_mode = true;
7061
7065
  }
7062
- profile_picture_source = 'factual';
7063
- factual_image_mode = true;
7064
7066
  }
7067
+ } else {
7068
+ factual_image_mode = true;
7069
+ profile_picture_source = 'factual';
7065
7070
  }
7066
- } else {
7067
- factual_image_mode = true;
7068
- profile_picture_source = 'factual';
7069
- }
7070
7071
 
7071
- if (factual_image_mode) {
7072
- imageBase64 = await create_image(uid, factual_prompt, undefined, undefined, 1, undefined, undefined, {}, account_profile_info);
7073
- } else {
7074
- const model = 'gpt-image-1-mini'; // 'chatgpt-image-latest';
7075
- const prompt = `
7072
+ if (factual_image_mode) {
7073
+ imageBase64 = await create_image(uid, factual_prompt, undefined, undefined, 1, undefined, undefined, {}, account_profile_info);
7074
+ } else {
7075
+ const model = 'gpt-image-1-mini'; // 'chatgpt-image-latest';
7076
+ const prompt = `
7076
7077
  extract the logo from the image
7077
7078
  `;
7078
- const image_response = await client.images.edit({
7079
- model,
7080
- image: image_blob_ret.image_blob,
7081
- prompt,
7082
- background: 'transparent',
7083
- });
7079
+ const image_response = await client.images.edit({
7080
+ model,
7081
+ image: image_blob_ret.image_blob,
7082
+ prompt,
7083
+ background: 'transparent',
7084
+ });
7084
7085
 
7085
- imageBase64 = await normalizeBase64To1024(image_response.data[0].b64_json, resize);
7086
- account_module.record_ai_usage(uid, image_response.usage.input_tokens, image_response.usage.output_tokens, 'profile image', prompt, model, { url }, account_profile_info);
7086
+ imageBase64 = await normalizeBase64To1024(image_response.data[0].b64_json, resize);
7087
+ account_module.record_ai_usage(uid, image_response.usage.input_tokens, image_response.usage.output_tokens, 'profile image', prompt, model, { url }, account_profile_info);
7088
+ }
7087
7089
  }
7088
7090
  const outputBuffer = Buffer.from(imageBase64, 'base64');
7089
7091
  const outputPath = tempOutputPath;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.4774",
3
+ "version": "1.1.4776",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",