@xuda.io/ai_module 1.1.5329 → 1.1.5331
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 +19 -4
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -3489,11 +3489,13 @@ export const create_conversation = async function (req, job_id, headers) {
|
|
|
3489
3489
|
}
|
|
3490
3490
|
}
|
|
3491
3491
|
|
|
3492
|
-
let { data: ai_credits } = await account_ms.get_account_ai_usage({ uid: account_profile_info.uid });
|
|
3492
|
+
// let { data: ai_credits } = await account_ms.get_account_ai_usage({ uid: account_profile_info.uid });
|
|
3493
3493
|
|
|
3494
|
-
if (ai_credits.credits.total - ai_credits.usage.total < -0.5) {
|
|
3495
|
-
|
|
3496
|
-
}
|
|
3494
|
+
// if (ai_credits.credits.total - ai_credits.usage.total < -0.5) {
|
|
3495
|
+
// throw new Error('ai credits reach to hard limit');
|
|
3496
|
+
// }
|
|
3497
|
+
|
|
3498
|
+
await validate_credits_limit(uid, profile_id);
|
|
3497
3499
|
|
|
3498
3500
|
let conversation_obj;
|
|
3499
3501
|
try {
|
|
@@ -5437,6 +5439,9 @@ export const create_avatar = async function (req, job_id, headers) {
|
|
|
5437
5439
|
|
|
5438
5440
|
const account_obj = await db_module.get_couch_doc_native('xuda_accounts', uid);
|
|
5439
5441
|
const account_info = account_obj.account_info;
|
|
5442
|
+
|
|
5443
|
+
// check credits
|
|
5444
|
+
|
|
5440
5445
|
if (!metadata) {
|
|
5441
5446
|
metadata = account_info;
|
|
5442
5447
|
}
|
|
@@ -11210,3 +11215,13 @@ export const get_chat_suggestions = async function (req) {
|
|
|
11210
11215
|
return { code: -44, data: err.message || String(err) };
|
|
11211
11216
|
}
|
|
11212
11217
|
};
|
|
11218
|
+
|
|
11219
|
+
const validate_credits_limit = async function (uid, profile_id) {
|
|
11220
|
+
const account_profile_info = await get_active_account_profile_info(uid, profile_id);
|
|
11221
|
+
|
|
11222
|
+
let { data: ai_credits } = await account_ms.get_account_ai_usage({ uid: account_profile_info.uid });
|
|
11223
|
+
|
|
11224
|
+
if (ai_credits.credits.total - ai_credits.usage.total < -0.5) {
|
|
11225
|
+
throw new Error('ai credits reach to hard limit');
|
|
11226
|
+
}
|
|
11227
|
+
};
|