@xuda.io/ai_module 1.1.5153 → 1.1.5155
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.
- package/index.mjs +25 -9
- 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
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
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);
|
|
@@ -4664,10 +4666,23 @@ const ai_chat_conversation = async function (req, job_id, headers) {
|
|
|
4664
4666
|
await attachment_handler(uid, app_id, conversation_id, attachments, account_profile_info);
|
|
4665
4667
|
}
|
|
4666
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
|
+
|
|
4667
4680
|
if (activate_prompt_suggestions) {
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
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) {
|
|
@@ -10874,6 +10889,7 @@ export const open_ai_alive_check = async function () {};
|
|
|
10874
10889
|
|
|
10875
10890
|
export const get_chat_suggestions = async function (uid, ai_agents, conversation_item_id, no_of_suggestions = 3, ai_model = _conf.default_ai_model) {
|
|
10876
10891
|
try {
|
|
10892
|
+
debugger;
|
|
10877
10893
|
const account_profile_info = await get_active_account_profile_info(uid);
|
|
10878
10894
|
const account_doc = await db_module.get_couch_doc_native('xuda_accounts', uid);
|
|
10879
10895
|
const conversation_item_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, conversation_item_id);
|