@xuda.io/ai_module 1.1.5600 → 1.1.5602

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 +27 -3
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -4302,6 +4302,7 @@ const contactGuardrailAgent = new Agent({
4302
4302
  // };
4303
4303
 
4304
4304
  export const submit_chat_conversation = async function (req, job_id, headers) {
4305
+ debugger;
4305
4306
  const { profile_id, uid, metadata = {}, accepted_plan_item_id } = req;
4306
4307
  let { conversation_id } = req;
4307
4308
  try {
@@ -4387,7 +4388,7 @@ export const submit_chat_conversation = async function (req, job_id, headers) {
4387
4388
  }
4388
4389
 
4389
4390
  case 'dashboard': {
4390
- ret = await dashboard_chat(req, job_id, headers);
4391
+ ret = conversation_doc.conversation_type === 'ai_chat' ? await ai_chat_conversation(req, job_id, headers) : await dashboard_chat(req, job_id, headers);
4391
4392
  break;
4392
4393
  }
4393
4394
 
@@ -5071,7 +5072,30 @@ const get_dashboard_cpi_zod_item = function (key, val = {}, options = {}) {
5071
5072
  let schema;
5072
5073
 
5073
5074
  if (val.enum?.length) {
5074
- schema = z.enum(val.enum);
5075
+ const enum_values = val.enum.filter((item) => typeof item !== 'undefined');
5076
+ if (!enum_values.length) {
5077
+ schema = z.string();
5078
+ } else if (enum_values.length === 1) {
5079
+ switch (typeof enum_values[0]) {
5080
+ case 'number':
5081
+ schema = z.number();
5082
+ break;
5083
+ case 'boolean':
5084
+ schema = z.boolean();
5085
+ break;
5086
+ default:
5087
+ schema = z.string();
5088
+ break;
5089
+ }
5090
+ } else if (enum_values.every((item) => typeof item === 'string')) {
5091
+ schema = z.enum(enum_values);
5092
+ } else if (enum_values.every((item) => typeof item === 'number')) {
5093
+ schema = z.number();
5094
+ } else if (enum_values.every((item) => typeof item === 'boolean')) {
5095
+ schema = z.boolean();
5096
+ } else {
5097
+ schema = z.string();
5098
+ }
5075
5099
  } else {
5076
5100
  switch (val.type) {
5077
5101
  case 'string':
@@ -5099,7 +5123,7 @@ const get_dashboard_cpi_zod_item = function (key, val = {}, options = {}) {
5099
5123
  break;
5100
5124
  }
5101
5125
  default:
5102
- schema = z.any();
5126
+ schema = z.string();
5103
5127
  break;
5104
5128
  }
5105
5129
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.5600",
3
+ "version": "1.1.5602",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",