@xuda.io/ai_module 1.1.5568 → 1.1.5570

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 +16 -3
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -2806,23 +2806,36 @@ export const create_ai_agent = async function (req, job_id, headers) {
2806
2806
  };
2807
2807
 
2808
2808
  export const update_ai_agent_properties = async function (doc, app_id, uid, fields_changed = {}) {
2809
- debugger;
2810
2809
  const db_doc = await db_module.get_app_couch_doc_native(app_id, doc._id);
2811
2810
  // const { account_profile_info } = doc.studio_meta;
2812
2811
  const account_profile_info = await get_active_account_profile_info(uid);
2813
2812
 
2814
2813
  const get_agent_assistant_name = async function () {
2814
+ const AssistantNameSchema = z.object({
2815
+ assistant_name: z.string().describe('A professional assistant name, maximum 3 words.'),
2816
+ });
2817
+
2815
2818
  const ret = await submit_chat_gpt_prompt({
2816
2819
  uid,
2817
2820
  prompt: `Generate a professional assistant name (e.g., “Data Analyst Assistant”) for the AI agent titled:
2818
2821
  “${doc.properties.menuName}” and also base on the instructions : "${doc.agentConfig.agent_instructions}"
2819
- Output one option 3 words max.`,
2822
+ Return JSON only with one field named assistant_name.
2823
+ Maximum 3 words.
2824
+ Do not return prompts, descriptions, explanations, punctuation lists, or multiple options.`,
2820
2825
  model: _conf.default_ai_model,
2826
+ response_format: AssistantNameSchema,
2821
2827
  metadata: { agent_id: db_doc._id, func: 'get_agent_assistant_name' },
2822
2828
  account_profile_info,
2823
2829
  });
2824
2830
 
2825
- return ret.data;
2831
+ try {
2832
+ const parsed = JSON5.parse(ret.data);
2833
+ const assistant_name = (parsed?.assistant_name || '').replace(/\s+/g, ' ').trim().split(' ').slice(0, 3).join(' ');
2834
+
2835
+ return assistant_name || 'AI Assistant';
2836
+ } catch (error) {
2837
+ return 'AI Assistant';
2838
+ }
2826
2839
  };
2827
2840
 
2828
2841
  const get_agent_category = async function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.5568",
3
+ "version": "1.1.5570",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",