@xuda.io/ai_module 1.1.5127 → 1.1.5128

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 +29 -19
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -10852,6 +10852,7 @@ export const get_chat_suggestions = async function (uid, ai_agents, conversation
10852
10852
  // auto agent mode
10853
10853
  const ai_agents_ret = await get_user_ai_agents(uid);
10854
10854
  for (const doc of ai_agents_ret.docs) {
10855
+ if (doc._id === conversation_item_doc.ai_agent_id) continue; //exclude the current agent from list
10855
10856
  ai_agents.push(doc._id);
10856
10857
  }
10857
10858
  }
@@ -10886,22 +10887,21 @@ export const get_chat_suggestions = async function (uid, ai_agents, conversation
10886
10887
  return list;
10887
10888
  };
10888
10889
 
10889
- const agents_docs = await get_agents();
10890
-
10891
- const AgentItemSchema = z.object({
10892
- agent_id: z.string().describe('The unique identifier for the agent'),
10893
- short_action: z.string().describe('A brief, 2-4 word call to action'),
10894
- agent_description: z.string().describe("A professional description of the agent's capabilities"),
10895
- });
10890
+ const get_suggestions = async function () {
10891
+ const AgentItemSchema = z.object({
10892
+ agent_id: z.string().describe('The unique identifier for the agent'),
10893
+ short_action: z.string().describe('A brief, 2-4 word call to action'),
10894
+ agent_description: z.string().describe("A professional description of the agent's capabilities"),
10895
+ });
10896
10896
 
10897
- // Define the response format as a fixed-length array of 5
10898
- const AgentResponseSchema = z.object({
10899
- agents: z.array(AgentItemSchema).length(5),
10900
- });
10897
+ // Define the response format as a fixed-length array of 5
10898
+ const AgentResponseSchema = z.object({
10899
+ agents: z.array(AgentItemSchema).length(5),
10900
+ });
10901
10901
 
10902
- const chat_ret = await submit_chat_gpt_prompt({
10903
- uid,
10904
- prompt: `
10902
+ const chat_ret = await submit_chat_gpt_prompt({
10903
+ uid,
10904
+ prompt: `
10905
10905
 
10906
10906
  Role: You are a routing assistant.
10907
10907
 
@@ -10923,11 +10923,21 @@ export const get_chat_suggestions = async function (uid, ai_agents, conversation
10923
10923
  [{agent_id:"392_agn_55cb328d2743",short_action:"Create article","agent_description":"create proffessional article..."}]
10924
10924
 
10925
10925
  `,
10926
- model: ai_model,
10927
- response_format: AgentResponseSchema,
10928
- metadata: { conversation_item_id, func: 'get_chat_suggestions' },
10929
- account_profile_info,
10930
- });
10926
+ model: ai_model,
10927
+ response_format: AgentResponseSchema,
10928
+ metadata: { conversation_item_id, func: 'get_chat_suggestions' },
10929
+ account_profile_info,
10930
+ });
10931
+ try {
10932
+ const ret = JSON5.parse(chat_ret.data);
10933
+ return ret.agents;
10934
+ } catch (error) {
10935
+ return [];
10936
+ }
10937
+ };
10938
+
10939
+ const agents_docs = await get_agents();
10940
+ const suggestions = await get_suggestions();
10931
10941
 
10932
10942
  debugger;
10933
10943
  } catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.5127",
3
+ "version": "1.1.5128",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",