@xuda.io/ai_module 1.1.4609 → 1.1.4611

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 +8 -8
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -4097,7 +4097,7 @@ function getFirstNWords(text, n = 10) {
4097
4097
  }
4098
4098
 
4099
4099
  export const create_conversation = async function (req, job_id, headers) {
4100
- const { profile_id, uid, prompt, perform_ai_execution = true, email_id, email_direction = 'out', from_mailbox } = req;
4100
+ const { profile_id, uid, prompt, perform_ai_execution = true, email_id, email_direction = 'out', from_mailbox, date_created } = req;
4101
4101
  let { reference_type, reference_id = '', conversation_type } = req;
4102
4102
 
4103
4103
  const account_profile_info = await account_module.get_active_account_profile_info(uid, profile_id);
@@ -4115,14 +4115,14 @@ export const create_conversation = async function (req, job_id, headers) {
4115
4115
  if (ai_credits.credits.total - ai_credits.usage.total < -0.5) {
4116
4116
  throw new Error('ai credits reach to hard limit');
4117
4117
  }
4118
-
4118
+ debugger;
4119
4119
  const conversation_obj = await client.conversations.create();
4120
4120
  const t = Date.now();
4121
4121
  let conversation_doc = {
4122
4122
  _id: await _common.xuda_get_uuid('chat_conversation'),
4123
4123
  docType: 'chat_conversation',
4124
4124
  title: conversation_type !== 'email' ? getFirstNWords(prompt, 10) : prompt,
4125
- date_created_ts: t,
4125
+ date_created_ts: Date.now(date_created),
4126
4126
  ts: t,
4127
4127
  stat: !conversation_type || conversation_type === 'ai' ? 1 : 3,
4128
4128
  uid,
@@ -7010,10 +7010,10 @@ export const get_business_info = async function (uid, name, email, account_profi
7010
7010
  }
7011
7011
  };
7012
7012
 
7013
- const get_chat_picture_cache = async function (uid, docType, name) {
7014
- if (!name || typeof name !== 'string') return null;
7013
+ const get_chat_picture_cache = async function (uid, docType, key) {
7014
+ if (!key || typeof key !== 'string') return null;
7015
7015
 
7016
- const words = name
7016
+ const words = key
7017
7017
  .trim()
7018
7018
  .toLowerCase()
7019
7019
  .split(/\s+/)
@@ -7022,7 +7022,7 @@ const get_chat_picture_cache = async function (uid, docType, name) {
7022
7022
  if (words.length < 3) {
7023
7023
  // Direct exact match for short names
7024
7024
  const ret = await db_module.find_couch_query('xuda_cache', {
7025
- selector: { docType, name: name.trim() },
7025
+ selector: { docType, key: key.toLowerCase().trim() },
7026
7026
  limit: 1,
7027
7027
  });
7028
7028
 
@@ -7046,7 +7046,7 @@ const get_chat_picture_cache = async function (uid, docType, name) {
7046
7046
  selector: {
7047
7047
  docType,
7048
7048
  $and: threeWords.map((word) => ({
7049
- name: { $regex: `(?i)\\b${word}\\b` },
7049
+ key: { $regex: `(?i)\\b${word}\\b` },
7050
7050
  })),
7051
7051
  },
7052
7052
  limit: 1,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.4609",
3
+ "version": "1.1.4611",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",