@xuda.io/account_module 1.2.2093 → 1.2.2094
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 +7 -3
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -1780,15 +1780,15 @@ export const ts_contact = async function (uid, contact_id) {
|
|
|
1780
1780
|
};
|
|
1781
1781
|
|
|
1782
1782
|
export const get_account_ai_usage = async function (req, job_id, headers) {
|
|
1783
|
-
const { uid,
|
|
1783
|
+
const { uid, year_from, month_from, day_from, year_to, month_to, day_to } = req;
|
|
1784
1784
|
try {
|
|
1785
1785
|
const d = new Date();
|
|
1786
1786
|
const curr_month = Number(String(d.getMonth() + 1).padStart(2, '0')); // months are 0-based
|
|
1787
1787
|
const curr_year = d.getFullYear();
|
|
1788
1788
|
|
|
1789
1789
|
const ai_usage = await db_module.get_couch_view('xuda_usage', 'ai_usage', {
|
|
1790
|
-
startkey: [uid,
|
|
1791
|
-
endkey: [uid,
|
|
1790
|
+
startkey: [uid, year_from || curr_year, month_from || curr_month, day_from || 0],
|
|
1791
|
+
endkey: [uid, year_to || curr_year, month_to || curr_month, day_to || 99],
|
|
1792
1792
|
reduce: true,
|
|
1793
1793
|
group_level: 999,
|
|
1794
1794
|
});
|
|
@@ -3303,6 +3303,8 @@ export const find_contact_query = async function (uid, opt) {
|
|
|
3303
3303
|
return ret;
|
|
3304
3304
|
};
|
|
3305
3305
|
|
|
3306
|
+
//////////////////////////////
|
|
3307
|
+
|
|
3306
3308
|
export const delete_xuda_cache = async function (contact_obj) {
|
|
3307
3309
|
const ret = await db_module.find_couch_query('xuda_cache', {
|
|
3308
3310
|
selector: {
|
|
@@ -3373,6 +3375,8 @@ export const save_cache_hit = async function (_id) {
|
|
|
3373
3375
|
}
|
|
3374
3376
|
};
|
|
3375
3377
|
|
|
3378
|
+
///////////////////////////////
|
|
3379
|
+
|
|
3376
3380
|
export const record_ai_usage = async function (uid, input_tokens, output_tokens, source, prompt, model, metadata = {}, account_profile_info, tools) {
|
|
3377
3381
|
try {
|
|
3378
3382
|
if (!account_profile_info) throw new Error('missing account_profile_info');
|