@xuda.io/ai_module 1.1.3837 → 1.1.3839

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 +6 -4
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -5669,13 +5669,15 @@ export const convert_profile_image_to_avatar = async function (req, job_id, head
5669
5669
  let imageBase64;
5670
5670
  let avatar_source = '';
5671
5671
  if (prompt) {
5672
+ const model = 'chatgpt-image-latest';
5672
5673
  const ai_avatar_response = await client.images.edit({
5673
- model: 'chatgpt-image-latest', // 'gpt-image-1',
5674
+ model, // 'gpt-image-1',
5674
5675
  image: images[0].image_blob, //base photo
5675
5676
  prompt,
5676
5677
  background: 'transparent',
5677
5678
  });
5678
5679
  imageBase64 = ai_avatar_response.data[0].b64_json;
5680
+ record_chat_usage(uid, ai_avatar_response.usage.input_tokens, ai_avatar_response.usage.output_tokens, 'create image', prompt, model);
5679
5681
  } else {
5680
5682
  //////////////////
5681
5683
  imageBase64 = Buffer.from(await images[0].image_blob.arrayBuffer()).toString('base64');
@@ -6175,9 +6177,9 @@ const create_ai_agent_image = async function (req, job_id, headers) {
6175
6177
 
6176
6178
  //////////////////
6177
6179
  imageBase64 = Buffer.from(await images[0].image_blob.arrayBuffer()).toString('base64');
6178
-
6180
+ const model = 'chatgpt-image-latest';
6179
6181
  const ai_avatar_response = await client.images.edit({
6180
- model: 'chatgpt-image-latest',
6182
+ model,
6181
6183
  image: images[0].image_blob,
6182
6184
 
6183
6185
  prompt: `
@@ -6205,7 +6207,7 @@ const create_ai_agent_image = async function (req, job_id, headers) {
6205
6207
  background: 'transparent',
6206
6208
  });
6207
6209
  imageBase64 = ai_avatar_response.data[0].b64_json;
6208
-
6210
+ record_chat_usage(uid, ai_avatar_response.usage.input_tokens, ai_avatar_response.usage.output_tokens, 'create image', prompt, model);
6209
6211
  console.log('Normalizing final avatar to 1024 with transparent padding...');
6210
6212
  imageBase64 = await normalizeBase64To1024(imageBase64);
6211
6213
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.3837",
3
+ "version": "1.1.3839",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",