@xuda.io/ai_module 1.1.5567 → 1.1.5569

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 +32 -3
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -2812,17 +2812,31 @@ export const update_ai_agent_properties = async function (doc, app_id, uid, fiel
2812
2812
  const account_profile_info = await get_active_account_profile_info(uid);
2813
2813
 
2814
2814
  const get_agent_assistant_name = async function () {
2815
+ const AssistantNameSchema = z.object({
2816
+ assistant_name: z.string().describe('A professional assistant name, maximum 3 words.'),
2817
+ });
2818
+
2815
2819
  const ret = await submit_chat_gpt_prompt({
2816
2820
  uid,
2817
2821
  prompt: `Generate a professional assistant name (e.g., “Data Analyst Assistant”) for the AI agent titled:
2818
2822
  “${doc.properties.menuName}” and also base on the instructions : "${doc.agentConfig.agent_instructions}"
2819
- Output one option 3 words max.`,
2823
+ Return JSON only with one field named assistant_name.
2824
+ Maximum 3 words.
2825
+ Do not return prompts, descriptions, explanations, punctuation lists, or multiple options.`,
2820
2826
  model: _conf.default_ai_model,
2827
+ response_format: AssistantNameSchema,
2821
2828
  metadata: { agent_id: db_doc._id, func: 'get_agent_assistant_name' },
2822
2829
  account_profile_info,
2823
2830
  });
2824
2831
 
2825
- return ret.data;
2832
+ try {
2833
+ const parsed = JSON5.parse(ret.data);
2834
+ const assistant_name = (parsed?.assistant_name || '').replace(/\s+/g, ' ').trim().split(' ').slice(0, 3).join(' ');
2835
+
2836
+ return assistant_name || 'AI Assistant';
2837
+ } catch (error) {
2838
+ return 'AI Assistant';
2839
+ }
2826
2840
  };
2827
2841
 
2828
2842
  const get_agent_category = async function () {
@@ -6590,7 +6604,9 @@ const create_ai_agent_image = async function (req, job_id, headers) {
6590
6604
  // const model = 'gpt-image-1-mini';
6591
6605
  const prompt = `
6592
6606
  Create a futuristic, profile portrait with a transparent background.
6593
- make the character look like the person from the provided image with complete metal face hairless ,
6607
+ Use the provided image only as loose inspiration for pose, framing, and general visual style.
6608
+ Do not preserve identity and do not create a photorealistic likeness.
6609
+ Make the character a complete metallic, hairless humanoid,
6594
6610
  The humanoid must remain completely metal.
6595
6611
  Center the character facing forward, with subtle top spacing, showing only the head and shoulders.
6596
6612
  Style the humanoid with functional, minimal attire integrated into its form (such as collars,
@@ -6622,6 +6638,19 @@ const create_ai_agent_image = async function (req, job_id, headers) {
6622
6638
  });
6623
6639
  report_ai_status(model);
6624
6640
  } catch (err) {
6641
+ if (err?.code === 'moderation_blocked') {
6642
+ const fallback_prompt = `
6643
+ Create a futuristic metallic humanoid portrait with transparent background.
6644
+ Head and shoulders only, centered, forward-facing.
6645
+ The design should represent "${ai_agent_doc.properties.menuName} - ${ai_agent_doc.studio_meta.agent_assistant_name}".
6646
+ Keep the character fully robotic and non-photorealistic.
6647
+ Use a consistent palette and emphasize intelligence, clarity, and sophistication.
6648
+ `;
6649
+
6650
+ const images_arr = await create_and_upload_image_to_drive('studio', 'Progs Thumbnails', ai_agent_id, fallback_prompt, 1, uid, app_id, job_id, headers, false, tags, account_profile_info);
6651
+ report_ai_status(model, err);
6652
+ return { code: 1, data: images_arr[0] };
6653
+ }
6625
6654
  report_ai_status(model, err);
6626
6655
  throw err;
6627
6656
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.5567",
3
+ "version": "1.1.5569",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",