@xuda.io/ai_module 1.1.5292 → 1.1.5294
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 +12 -12
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -4059,10 +4059,12 @@ const ai_chat_conversation = async function (req, job_id, headers) {
|
|
|
4059
4059
|
const account_profile_info = await get_active_account_profile_info(uid, profile_id);
|
|
4060
4060
|
let { prompt, conversation_doc, attachments = [], ai_agents, output_format = 'md', stream = true, with_context = true, ai_model = _conf.default_ai_model } = req;
|
|
4061
4061
|
|
|
4062
|
+
let local_ai_agents = _.cloneDeep(ai_agents);
|
|
4063
|
+
|
|
4062
4064
|
const reference_type = conversation_doc.reference_type;
|
|
4063
4065
|
const reference_id = conversation_doc.reference_id;
|
|
4064
4066
|
|
|
4065
|
-
const activate_prompt_suggestions = _.isArray(
|
|
4067
|
+
const activate_prompt_suggestions = _.isArray(local_ai_agents) && conversation_doc.reference_type !== 'ai_agents' && !conversation_item_id;
|
|
4066
4068
|
let prompt_suggestion_activated;
|
|
4067
4069
|
let model = ai_model;
|
|
4068
4070
|
if (!_conf.ai_models[model]) {
|
|
@@ -4217,8 +4219,6 @@ const ai_chat_conversation = async function (req, job_id, headers) {
|
|
|
4217
4219
|
}
|
|
4218
4220
|
};
|
|
4219
4221
|
|
|
4220
|
-
// const suggestionsPromise = activate_prompt_suggestions ? get_chat_suggestions({ uid, ai_agents, conversation_item_id: out_conversation_item_save_ret.data.id, context: prompt }) : Promise.resolve(null);
|
|
4221
|
-
|
|
4222
4222
|
conversation_doc.stat = 2;
|
|
4223
4223
|
conversation_doc.ts = Date.now();
|
|
4224
4224
|
conversation_doc.ai_agents = ai_agents;
|
|
@@ -4313,14 +4313,14 @@ const ai_chat_conversation = async function (req, job_id, headers) {
|
|
|
4313
4313
|
return is_agent ? identity : triage_assistant + identity;
|
|
4314
4314
|
};
|
|
4315
4315
|
const get_agents = async function () {
|
|
4316
|
-
if (typeof
|
|
4316
|
+
if (typeof local_ai_agents === 'undefined') {
|
|
4317
4317
|
// no agents
|
|
4318
|
-
|
|
4319
|
-
} else if (!
|
|
4318
|
+
local_ai_agents = [];
|
|
4319
|
+
} else if (!local_ai_agents.length) {
|
|
4320
4320
|
// auto agent mode
|
|
4321
4321
|
const ai_agents_ret = await get_user_ai_agents(uid);
|
|
4322
4322
|
for (const doc of ai_agents_ret.docs) {
|
|
4323
|
-
|
|
4323
|
+
local_ai_agents.push(doc._id);
|
|
4324
4324
|
}
|
|
4325
4325
|
}
|
|
4326
4326
|
|
|
@@ -4329,12 +4329,12 @@ const ai_chat_conversation = async function (req, job_id, headers) {
|
|
|
4329
4329
|
let modelSettings = {};
|
|
4330
4330
|
|
|
4331
4331
|
if (reference_type === 'ai_agents') {
|
|
4332
|
-
|
|
4332
|
+
local_ai_agents.push(reference_id);
|
|
4333
4333
|
}
|
|
4334
4334
|
|
|
4335
4335
|
let eligible_agent = true;
|
|
4336
4336
|
|
|
4337
|
-
for (const agent_id of
|
|
4337
|
+
for (const agent_id of local_ai_agents) {
|
|
4338
4338
|
try {
|
|
4339
4339
|
let ai_agent_doc;
|
|
4340
4340
|
try {
|
|
@@ -4731,7 +4731,7 @@ const ai_chat_conversation = async function (req, job_id, headers) {
|
|
|
4731
4731
|
counter++;
|
|
4732
4732
|
const job_info = await jobs_ms.get_job_info({ job_id });
|
|
4733
4733
|
|
|
4734
|
-
if (counter >
|
|
4734
|
+
if (counter > 50) {
|
|
4735
4735
|
resolve(null);
|
|
4736
4736
|
} else {
|
|
4737
4737
|
if (job_info.code < 0 || job_info.data.stat === 4) {
|
|
@@ -4798,7 +4798,7 @@ const ai_chat_conversation = async function (req, job_id, headers) {
|
|
|
4798
4798
|
prompt_selected_suggestion = await render_suggestions();
|
|
4799
4799
|
if (prompt_selected_suggestion) {
|
|
4800
4800
|
prompt_suggestion_activated = true;
|
|
4801
|
-
|
|
4801
|
+
local_ai_agents = prompt_selected_suggestion;
|
|
4802
4802
|
agents = await get_agents();
|
|
4803
4803
|
} else {
|
|
4804
4804
|
emitToDashboard('response_start');
|
|
@@ -4922,7 +4922,7 @@ const ai_chat_conversation = async function (req, job_id, headers) {
|
|
|
4922
4922
|
let string_debug = '';
|
|
4923
4923
|
let chunks = 0;
|
|
4924
4924
|
for await (const chunk of output_stream) {
|
|
4925
|
-
console.log(chunks);
|
|
4925
|
+
// console.log(chunks);
|
|
4926
4926
|
if (chunks % 10 === 0) {
|
|
4927
4927
|
const job_info = await jobs_ms.get_job_info({ job_id });
|
|
4928
4928
|
if (job_info.code < 0 || job_info.data.stat === 4) {
|