@xuda.io/ai_module 1.1.5328 → 1.1.5330

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 +17 -2
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -4837,7 +4837,8 @@ const ai_chat_conversation = async function (req, job_id, headers) {
4837
4837
  stream,
4838
4838
  };
4839
4839
 
4840
- await update_job('submitting chat');
4840
+ // await update_job('submitting chat');
4841
+ emitToDashboard('stream_phase', 'Submitting chat');
4841
4842
  init_agent_hooks(_agent);
4842
4843
  // const output = await runner.run(_agent, prompt, opt);
4843
4844
  const output = await run_agent(_agent, prompt, opt);
@@ -4941,7 +4942,8 @@ const ai_chat_conversation = async function (req, job_id, headers) {
4941
4942
  if (!response_start) {
4942
4943
  response_start = true;
4943
4944
 
4944
- await update_job('streaming results');
4945
+ // await update_job('streaming results');
4946
+ emitToDashboard('stream_phase', 'Streaming results');
4945
4947
  emitToDashboard('response_start');
4946
4948
  }
4947
4949
  const text = chunk.toString();
@@ -5435,6 +5437,9 @@ export const create_avatar = async function (req, job_id, headers) {
5435
5437
 
5436
5438
  const account_obj = await db_module.get_couch_doc_native('xuda_accounts', uid);
5437
5439
  const account_info = account_obj.account_info;
5440
+
5441
+ // check credits
5442
+
5438
5443
  if (!metadata) {
5439
5444
  metadata = account_info;
5440
5445
  }
@@ -11208,3 +11213,13 @@ export const get_chat_suggestions = async function (req) {
11208
11213
  return { code: -44, data: err.message || String(err) };
11209
11214
  }
11210
11215
  };
11216
+
11217
+ const validate_credits_limit = async function (uid, profile_id) {
11218
+ const account_profile_info = await get_active_account_profile_info(uid, profile_id);
11219
+
11220
+ let { data: ai_credits } = await account_ms.get_account_ai_usage({ uid: account_profile_info.uid });
11221
+
11222
+ if (ai_credits.credits.total - ai_credits.usage.total < -0.5) {
11223
+ throw new Error('ai credits reach to hard limit');
11224
+ }
11225
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.5328",
3
+ "version": "1.1.5330",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",