@xuda.io/ai_module 1.1.5165 → 1.1.5167
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 +6 -12
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -4053,7 +4053,7 @@ const ai_chat_conversation = async function (req, job_id, headers) {
|
|
|
4053
4053
|
const reference_type = conversation_doc.reference_type;
|
|
4054
4054
|
const reference_id = conversation_doc.reference_id;
|
|
4055
4055
|
|
|
4056
|
-
const activate_prompt_suggestions = _.isArray(ai_agents) && conversation_doc.reference_type !== 'ai_agents';
|
|
4056
|
+
const activate_prompt_suggestions = _.isArray(ai_agents) && conversation_doc.reference_type !== 'ai_agents' && !conversation_item_id;
|
|
4057
4057
|
|
|
4058
4058
|
let model = ai_model;
|
|
4059
4059
|
if (!_conf.ai_models[model]) {
|
|
@@ -4081,7 +4081,10 @@ const ai_chat_conversation = async function (req, job_id, headers) {
|
|
|
4081
4081
|
direction: 'out',
|
|
4082
4082
|
role: 'user',
|
|
4083
4083
|
};
|
|
4084
|
-
|
|
4084
|
+
let out_conversation_item_save_ret = await db_module.save_app_couch_doc(account_profile_info.app_id, out_conversation_item_obj);
|
|
4085
|
+
if (!conversation_item_id) {
|
|
4086
|
+
out_conversation_item_save_ret = await db_module.save_app_couch_doc(account_profile_info.app_id, out_conversation_item_obj);
|
|
4087
|
+
}
|
|
4085
4088
|
|
|
4086
4089
|
// const { account_profile_info } = conversation_doc;
|
|
4087
4090
|
const emitToDashboard = (type, content) => {
|
|
@@ -4118,7 +4121,7 @@ const ai_chat_conversation = async function (req, job_id, headers) {
|
|
|
4118
4121
|
};
|
|
4119
4122
|
|
|
4120
4123
|
try {
|
|
4121
|
-
if (out_conversation_item_save_ret.code < 0) throw new Error(out_conversation_item_save_ret.data);
|
|
4124
|
+
if (!conversation_item_id && out_conversation_item_save_ret.code < 0) throw new Error(out_conversation_item_save_ret.data);
|
|
4122
4125
|
|
|
4123
4126
|
if (conversation_item_id) {
|
|
4124
4127
|
const conversation_item_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, conversation_item_id);
|
|
@@ -4163,15 +4166,6 @@ const ai_chat_conversation = async function (req, job_id, headers) {
|
|
|
4163
4166
|
// await _utils.delay(500);
|
|
4164
4167
|
await update_job('initiating conversation');
|
|
4165
4168
|
let prompt_suggestions = [];
|
|
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
|
-
// let conversation_doc = await db_module.get_app_couch_doc_native(app_id, conversation_id);
|
|
4173
|
-
// const reference_type = conversation_doc.reference_type;
|
|
4174
|
-
// const reference_id = conversation_doc.reference_id;
|
|
4175
4169
|
|
|
4176
4170
|
const suggestionsPromise = activate_prompt_suggestions ? get_chat_suggestions({ uid, ai_agents, conversation_item_id: out_conversation_item_save_ret.data.id }) : Promise.resolve(null);
|
|
4177
4171
|
|