@xuda.io/ai_module 1.1.5099 → 1.1.5101

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 +60 -0
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -10853,3 +10853,63 @@ export const open_ai_alive_check = async function () {};
10853
10853
 
10854
10854
  // return account_profile_info;
10855
10855
  // };
10856
+
10857
+ export const get_chat_suggestions = async function (uid, conversation_item_id, ai_agents, ai_model = _conf.default_ai_model) {
10858
+ let ret = [];
10859
+ try {
10860
+ const get_agents = async function () {
10861
+ if (typeof ai_agents === 'undefined') {
10862
+ // no agents
10863
+ ai_agents = [];
10864
+ } else if (!ai_agents.length) {
10865
+ // auto agent mode
10866
+ const ai_agents_ret = await get_user_ai_agents(uid);
10867
+ for (const doc of ai_agents_ret.docs) {
10868
+ ai_agents.push(doc._id);
10869
+ }
10870
+ }
10871
+
10872
+ const list = [];
10873
+
10874
+ let modelSettings = {};
10875
+
10876
+ for (const agent_id of ai_agents) {
10877
+ try {
10878
+ let ai_agent_doc;
10879
+ try {
10880
+ ai_agent_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, agent_id);
10881
+ if (ai_agent_doc.studio_meta.shared_from_uid) {
10882
+ const reference_doc = _.cloneDeep(ai_agent_doc);
10883
+ const app_id = await get_account_default_project_id(ai_agent_doc.studio_meta.shared_from_uid);
10884
+ ai_agent_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, ai_agent_doc.studio_meta.share_item_id);
10885
+ ai_agent_doc.reference_doc = reference_doc;
10886
+ } else if (ai_agent_doc.studio_meta.installed_from_uid) {
10887
+ const reference_doc = _.cloneDeep(ai_agent_doc);
10888
+ const app_id = await get_account_default_project_id(ai_agent_doc.studio_meta.installed_from_uid);
10889
+ ai_agent_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, ai_agent_doc.studio_meta.share_item_id);
10890
+ ai_agent_doc.reference_doc = reference_doc;
10891
+ }
10892
+ } catch (err) {
10893
+ throw new Error(err.message);
10894
+ }
10895
+
10896
+ if (ai_agent_doc.agent_ai_model) {
10897
+ model = ai_agent_doc.agent_ai_model;
10898
+ }
10899
+
10900
+ if (ai_agent_doc.use_tools_only) {
10901
+ modelSettings.toolChoice = 'required';
10902
+ }
10903
+ } catch (err) {
10904
+ console.error(err.message);
10905
+ }
10906
+ }
10907
+ //tell me more on xuda
10908
+ // debugger;
10909
+
10910
+ return list;
10911
+ };
10912
+ } catch (err) {
10913
+ return { code: -44, data: err.message || String(err) };
10914
+ }
10915
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.5099",
3
+ "version": "1.1.5101",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",