@xuda.io/ai_module 1.1.5329 → 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.
- package/index.mjs +13 -0
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -5437,6 +5437,9 @@ export const create_avatar = async function (req, job_id, headers) {
|
|
|
5437
5437
|
|
|
5438
5438
|
const account_obj = await db_module.get_couch_doc_native('xuda_accounts', uid);
|
|
5439
5439
|
const account_info = account_obj.account_info;
|
|
5440
|
+
|
|
5441
|
+
// check credits
|
|
5442
|
+
|
|
5440
5443
|
if (!metadata) {
|
|
5441
5444
|
metadata = account_info;
|
|
5442
5445
|
}
|
|
@@ -11210,3 +11213,13 @@ export const get_chat_suggestions = async function (req) {
|
|
|
11210
11213
|
return { code: -44, data: err.message || String(err) };
|
|
11211
11214
|
}
|
|
11212
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
|
+
};
|