@xuda.io/ai_module 1.1.5568 → 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.
- package/index.mjs +16 -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
|
-
|
|
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
|
-
|
|
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 () {
|