@xuda.io/ai_module 1.1.3812 → 1.1.3814
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 +25 -0
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -6241,3 +6241,28 @@ const create_ai_agent_image = async function (req, job_id, headers) {
|
|
|
6241
6241
|
}
|
|
6242
6242
|
}
|
|
6243
6243
|
};
|
|
6244
|
+
|
|
6245
|
+
const record_chat_usage = async function (uid, input_tokens, output_tokens, msg) {
|
|
6246
|
+
try {
|
|
6247
|
+
const app_id = await account_module.get_account_default_project_id(uid);
|
|
6248
|
+
|
|
6249
|
+
const t = Date.now();
|
|
6250
|
+
let usage_doc = {
|
|
6251
|
+
_id: conversation_obj.id,
|
|
6252
|
+
docType: 'chat_usage',
|
|
6253
|
+
title: prompt.substr(0, 40),
|
|
6254
|
+
date_created_ts: t,
|
|
6255
|
+
ts: t,
|
|
6256
|
+
stat: 1,
|
|
6257
|
+
uid,
|
|
6258
|
+
messages: [],
|
|
6259
|
+
reference_type,
|
|
6260
|
+
reference_id,
|
|
6261
|
+
conversation_obj,
|
|
6262
|
+
conversation_type,
|
|
6263
|
+
initiator_uid: uid,
|
|
6264
|
+
};
|
|
6265
|
+
} catch (err) {
|
|
6266
|
+
console.error(err);
|
|
6267
|
+
}
|
|
6268
|
+
};
|