@xuda.io/ai_module 1.1.4251 → 1.1.4253

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 +9 -8
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -4474,7 +4474,7 @@ const chat_note = async function (req, job_id, headers) {
4474
4474
  sender_conversation_doc.messages.push(obj);
4475
4475
  await db_module.save_app_couch_doc_native(sender_app_id, sender_conversation_doc);
4476
4476
 
4477
- await db_module.save_app_couch_doc_native(sender_app_id, { _id: obj.id, stat: 3, docType: 'chat_conversation_item', uid, conversation_type: obj.conversation_type, date_created_ts: obj.ts, conversation_id, body });
4477
+ await db_module.save_app_couch_doc_native(sender_app_id, { _id: obj.id, stat: 3, docType: 'chat_conversation_item', ts: obj.ts, uid, conversation_type: obj.conversation_type, date_created_ts: obj.ts, conversation_id, body });
4478
4478
 
4479
4479
  return { code: 15, data: item };
4480
4480
  } catch (err) {
@@ -4509,7 +4509,7 @@ const chat_email = async function (req, job_id, headers) {
4509
4509
  sender_conversation_doc.messages.push(obj);
4510
4510
  await db_module.save_app_couch_doc_native(sender_app_id, sender_conversation_doc);
4511
4511
 
4512
- await db_module.save_app_couch_doc_native(sender_app_id, { _id: obj.id, stat: 3, docType: 'chat_conversation_item', uid, conversation_type: obj.conversation_type, date_created_ts: obj.ts, conversation_id, body });
4512
+ await db_module.save_app_couch_doc_native(sender_app_id, { _id: obj.id, stat: 3, docType: 'chat_conversation_item', ts: obj.ts, uid, conversation_type: obj.conversation_type, date_created_ts: obj.ts, conversation_id, body });
4513
4513
 
4514
4514
  return { code: 15, data: item };
4515
4515
  } catch (err) {
@@ -5143,13 +5143,14 @@ const ai_chat_conversation = async function (req, job_id, headers) {
5143
5143
  uid,
5144
5144
  conversation_type: obj.conversation_type,
5145
5145
  date_created_ts: obj.ts,
5146
+ ts: obj.ts,
5146
5147
  conversation_id,
5147
5148
  output: output.output,
5148
5149
  prompt,
5149
5150
  response: output.state._currentStep.output,
5150
5151
  });
5151
5152
 
5152
- record_chat_usage(uid, inputTokens, outputTokens, 'conversation chat', prompt, model, { conversation_id, ai_agent_id: obj.ai_agent_id, item_id: obj.id });
5153
+ record_chat_usage(uid, inputTokens, outputTokens, 'conversation chat', prompt, model, { conversation_id, ai_agent_id: obj.ai_agent_id, item_id: obj.id }, account_profile_info);
5153
5154
  // if (!conversation_doc.chat_image && (!conversation_doc.thumbnail_request_ts || Date.now() - conversation_doc.thumbnail_request_ts > 120000)) {
5154
5155
  // update_thumbnail('conversation', conversation_doc, app_id, uid, job_id, headers);
5155
5156
  // }
@@ -5775,7 +5776,7 @@ export const create_profile_avatar = async function (req, job_id, headers) {
5775
5776
  background: 'transparent',
5776
5777
  });
5777
5778
  imageBase64 = ai_avatar_response.data[0].b64_json;
5778
- record_chat_usage(uid, ai_avatar_response.usage.input_tokens, ai_avatar_response.usage.output_tokens, 'profile avatar', prompt, model, { url });
5779
+ record_chat_usage(uid, ai_avatar_response.usage.input_tokens, ai_avatar_response.usage.output_tokens, 'profile avatar', prompt, model, { url }, account_profile_info);
5779
5780
  } else {
5780
5781
  //////////////////
5781
5782
  imageBase64 = Buffer.from(await images[0].image_blob.arrayBuffer()).toString('base64');
@@ -5853,7 +5854,7 @@ export const create_profile_avatar = async function (req, job_id, headers) {
5853
5854
  The background should be fully removed, remove trees,clouds,sky or any landscape objects`,
5854
5855
  background: 'transparent',
5855
5856
  });
5856
- record_chat_usage(uid, ai_avatar_response.usage.input_tokens, ai_avatar_response.usage.output_tokens, 'profile avatar', prompt, model, { url });
5857
+ record_chat_usage(uid, ai_avatar_response.usage.input_tokens, ai_avatar_response.usage.output_tokens, 'profile avatar', prompt, model, { url }, account_profile_info);
5857
5858
  imageBase64 = ai_avatar_response.data[0].b64_json;
5858
5859
  avatar_source = 'fictional';
5859
5860
  } else {
@@ -5870,7 +5871,7 @@ export const create_profile_avatar = async function (req, job_id, headers) {
5870
5871
  Context: ${JSON.stringify({ first_name, last_name, bio, country, mainCategory, subCategory })}`,
5871
5872
  background: 'transparent',
5872
5873
  });
5873
- record_chat_usage(uid, ai_avatar_response.usage.input_tokens, ai_avatar_response.usage.output_tokens, 'profile avatar', prompt, model, { url });
5874
+ record_chat_usage(uid, ai_avatar_response.usage.input_tokens, ai_avatar_response.usage.output_tokens, 'profile avatar', prompt, model, { url }, account_profile_info);
5874
5875
  imageBase64 = ai_avatar_response.data[0].b64_json;
5875
5876
  avatar_source = 'ai profile';
5876
5877
  };
@@ -6324,7 +6325,7 @@ const create_ai_agent_image = async function (req, job_id, headers) {
6324
6325
  background: 'transparent',
6325
6326
  });
6326
6327
  imageBase64 = ai_avatar_response.data[0].b64_json;
6327
- record_chat_usage(uid, ai_avatar_response.usage.input_tokens, ai_avatar_response.usage.output_tokens, 'agent avatar', prompt, model, { ai_agent_id });
6328
+ record_chat_usage(uid, ai_avatar_response.usage.input_tokens, ai_avatar_response.usage.output_tokens, 'agent avatar', prompt, model, { ai_agent_id }, account_profile_info);
6328
6329
  console.log('Normalizing final avatar to 1024 with transparent padding...');
6329
6330
  imageBase64 = await normalizeBase64To1024(imageBase64);
6330
6331
 
@@ -6621,7 +6622,7 @@ const attachment_handler = async function (uid, app_id, conversation_id, attachm
6621
6622
  });
6622
6623
  system_message_items.push({ id: items.last_id, ts: Date.now(), conversation_type: 'attachment', file });
6623
6624
 
6624
- await db_module.save_app_couch_doc_native(uid, { _id: obj.id, stat: 3, docType: 'chat_conversation_item', uid, conversation_type: obj.conversation_type, date_created_ts: obj.ts, conversation_id, file, transcript });
6625
+ await db_module.save_app_couch_doc_native(uid, { _id: obj.id, stat: 3, docType: 'chat_conversation_item', ts: obj.ts, uid, conversation_type: obj.conversation_type, date_created_ts: obj.ts, conversation_id, file, transcript });
6625
6626
  }
6626
6627
 
6627
6628
  // const items = await client.conversations.items.create(conversation_id, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.4251",
3
+ "version": "1.1.4253",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",