@xuda.io/ai_module 1.1.5152 → 1.1.5154

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 +24 -9
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -4163,16 +4163,18 @@ const ai_chat_conversation = async function (req, job_id, headers) {
4163
4163
  // await _utils.delay(500);
4164
4164
  await update_job('initiating conversation');
4165
4165
  let prompt_suggestions = [];
4166
- setTimeout(async () => {
4167
- debugger;
4168
- if (!activate_prompt_suggestions) return;
4169
- const prompt_suggestions_ret = await get_chat_suggestions(uid, ai_agents, out_conversation_item_save_ret.data.id);
4170
- if (prompt_suggestions_ret.code > -1) prompt_suggestions = prompt_suggestions_ret.data;
4171
- }, 1);
4166
+ // setTimeout(async () => {
4167
+ // if (!activate_prompt_suggestions) return;
4168
+ // const prompt_suggestions_ret = await get_chat_suggestions(uid, ai_agents, out_conversation_item_save_ret.data.id);
4169
+ // debugger;
4170
+ // if (prompt_suggestions_ret.code > -1) prompt_suggestions = prompt_suggestions_ret.data;
4171
+ // }, 1);
4172
4172
  // let conversation_doc = await db_module.get_app_couch_doc_native(app_id, conversation_id);
4173
4173
  // const reference_type = conversation_doc.reference_type;
4174
4174
  // const reference_id = conversation_doc.reference_id;
4175
4175
 
4176
+ const suggestionsPromise = activate_prompt_suggestions ? get_chat_suggestions(uid, ai_agents, out_conversation_item_save_ret.data.id) : Promise.resolve(null);
4177
+
4176
4178
  conversation_doc.stat = 2;
4177
4179
  conversation_doc.ts = Date.now();
4178
4180
  await db_module.save_app_couch_doc_native(account_profile_info.app_id, conversation_doc);
@@ -4651,7 +4653,6 @@ const ai_chat_conversation = async function (req, job_id, headers) {
4651
4653
  }
4652
4654
  };
4653
4655
 
4654
- debugger;
4655
4656
  // try {
4656
4657
  const runner = new Runner();
4657
4658
  let _agent = [];
@@ -4665,9 +4666,23 @@ const ai_chat_conversation = async function (req, job_id, headers) {
4665
4666
  await attachment_handler(uid, app_id, conversation_id, attachments, account_profile_info);
4666
4667
  }
4667
4668
  ////////////
4669
+ // if (activate_prompt_suggestions) {
4670
+ // debugger;
4671
+ // if (!prompt_suggestions.length) {
4672
+ // await _utils.delay(10000);
4673
+ // }
4674
+
4675
+ // if (prompt_suggestions.length) {
4676
+ // await render_suggestions();
4677
+ // }
4678
+ // }
4679
+
4668
4680
  if (activate_prompt_suggestions) {
4669
- if (!prompt_suggestions.length) {
4670
- await _utils.delay(5000);
4681
+ // 2. Now wait for it specifically
4682
+ const prompt_suggestions_ret = await suggestionsPromise;
4683
+
4684
+ if (prompt_suggestions_ret && prompt_suggestions_ret.code > -1) {
4685
+ prompt_suggestions = prompt_suggestions_ret.data;
4671
4686
  }
4672
4687
 
4673
4688
  if (prompt_suggestions.length) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.5152",
3
+ "version": "1.1.5154",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",