@xuda.io/ai_module 1.1.5598 → 1.1.5599
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 +4 -53
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -4325,13 +4325,6 @@ export const submit_chat_conversation = async function (req, job_id, headers) {
|
|
|
4325
4325
|
}
|
|
4326
4326
|
|
|
4327
4327
|
const normalized_plan_mode = accepted_plan_item_id ? false : normalize_boolean(req.plan_mode ?? conversation_doc.plan_mode);
|
|
4328
|
-
const route_to_studio = conversation_doc.conversation_type === 'studio' || req.conversation_type === 'studio' || normalized_plan_mode || Boolean(accepted_plan_item_id);
|
|
4329
|
-
|
|
4330
|
-
if (route_to_studio && conversation_doc.conversation_type !== 'studio') {
|
|
4331
|
-
conversation_doc.conversation_type = 'studio';
|
|
4332
|
-
conversation_doc.plan_mode = normalized_plan_mode;
|
|
4333
|
-
await db_module.save_app_couch_doc_native(account_profile_info.app_id, conversation_doc);
|
|
4334
|
-
}
|
|
4335
4328
|
|
|
4336
4329
|
req.plan_mode = normalized_plan_mode;
|
|
4337
4330
|
req.conversation_doc = conversation_doc;
|
|
@@ -4339,9 +4332,6 @@ export const submit_chat_conversation = async function (req, job_id, headers) {
|
|
|
4339
4332
|
req.metadata = metadata || {};
|
|
4340
4333
|
let ret;
|
|
4341
4334
|
|
|
4342
|
-
// if (route_to_studio) {
|
|
4343
|
-
// ret = await chat_studio(req, job_id, headers);
|
|
4344
|
-
// } else {
|
|
4345
4335
|
switch (conversation_doc.reference_type) {
|
|
4346
4336
|
case 'contacts': {
|
|
4347
4337
|
req._thread_reentry = Date.now() - conversation_doc.date_created_ts > 60000;
|
|
@@ -4405,42 +4395,6 @@ export const submit_chat_conversation = async function (req, job_id, headers) {
|
|
|
4405
4395
|
ret = await ai_chat_conversation(req, job_id, headers);
|
|
4406
4396
|
break;
|
|
4407
4397
|
}
|
|
4408
|
-
// }
|
|
4409
|
-
|
|
4410
|
-
// if (route_to_studio) {
|
|
4411
|
-
// ret = await chat_studio(req, job_id, headers);
|
|
4412
|
-
// } else if (conversation_doc.reference_type === 'contacts') {
|
|
4413
|
-
// req._thread_reentry = Date.now() - conversation_doc.date_created_ts > 60000;
|
|
4414
|
-
|
|
4415
|
-
// account_msa.ts_contact(uid, conversation_doc.reference_id);
|
|
4416
|
-
|
|
4417
|
-
// switch (conversation_doc.conversation_type) {
|
|
4418
|
-
// case 'note': {
|
|
4419
|
-
// ret = await chat_note(req, job_id, headers);
|
|
4420
|
-
// break;
|
|
4421
|
-
// }
|
|
4422
|
-
// case 'ai_chat': {
|
|
4423
|
-
// ret = await ai_chat_conversation(req, job_id, headers);
|
|
4424
|
-
// break;
|
|
4425
|
-
// }
|
|
4426
|
-
|
|
4427
|
-
// case 'email': {
|
|
4428
|
-
// ret = await chat_email(req, job_id, headers);
|
|
4429
|
-
// break;
|
|
4430
|
-
// }
|
|
4431
|
-
|
|
4432
|
-
// case 'chat': {
|
|
4433
|
-
// ret = await contact_chat_conversation(req, job_id, headers);
|
|
4434
|
-
// break;
|
|
4435
|
-
// }
|
|
4436
|
-
|
|
4437
|
-
// default:
|
|
4438
|
-
// ret = { code: -44, data: 'invalid conversation_type ' + conversation_doc.conversation_type };
|
|
4439
|
-
// break;
|
|
4440
|
-
// }
|
|
4441
|
-
// } else {
|
|
4442
|
-
// ret = await ai_chat_conversation(req, job_id, headers);
|
|
4443
|
-
// }
|
|
4444
4398
|
|
|
4445
4399
|
if (ret.code > -1) {
|
|
4446
4400
|
let conversation_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, conversation_id);
|
|
@@ -5113,7 +5067,7 @@ const get_dashboard_cpi_keywords = function (context, prompt = '') {
|
|
|
5113
5067
|
return [];
|
|
5114
5068
|
};
|
|
5115
5069
|
|
|
5116
|
-
const get_dashboard_cpi_zod_item = function (key, val = {}) {
|
|
5070
|
+
const get_dashboard_cpi_zod_item = function (key, val = {}, options = {}) {
|
|
5117
5071
|
let schema;
|
|
5118
5072
|
|
|
5119
5073
|
if (val.enum?.length) {
|
|
@@ -5139,10 +5093,7 @@ const get_dashboard_cpi_zod_item = function (key, val = {}) {
|
|
|
5139
5093
|
const fields = val.items?.properties || val.properties || {};
|
|
5140
5094
|
const required = val.items?.required || val.required || [];
|
|
5141
5095
|
for (const [item_key, item_val] of Object.entries(fields)) {
|
|
5142
|
-
props[item_key] = get_dashboard_cpi_zod_item(item_key, item_val);
|
|
5143
|
-
if (!required.includes(item_key)) {
|
|
5144
|
-
props[item_key] = props[item_key].optional();
|
|
5145
|
-
}
|
|
5096
|
+
props[item_key] = get_dashboard_cpi_zod_item(item_key, item_val, { nullable: !required.includes(item_key) });
|
|
5146
5097
|
}
|
|
5147
5098
|
schema = z.object(props);
|
|
5148
5099
|
break;
|
|
@@ -5153,8 +5104,8 @@ const get_dashboard_cpi_zod_item = function (key, val = {}) {
|
|
|
5153
5104
|
}
|
|
5154
5105
|
}
|
|
5155
5106
|
|
|
5156
|
-
if (!val.mandatory) {
|
|
5157
|
-
schema = schema.
|
|
5107
|
+
if (options.nullable || !val.mandatory) {
|
|
5108
|
+
schema = schema.nullable();
|
|
5158
5109
|
}
|
|
5159
5110
|
|
|
5160
5111
|
const valid_values = val.options?.length ? ` Valid values: ${val.options.join(', ')}.` : '';
|