@xuda.io/account_module 1.2.2093 → 1.2.2095

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 +10 -3
  2. 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, year, month, day, usage_scope = 'account' } = req;
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, year || curr_year, month || curr_month, day || 0],
1791
- endkey: [uid, year || curr_year, month || curr_month, day || 99],
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
  });
@@ -1850,6 +1850,9 @@ export const get_account_ai_usage = async function (req, job_id, headers) {
1850
1850
 
1851
1851
  let data = { credits: { ...credits_obj, total: total_credits }, usage: { profile, projects: [], total: total_usage } };
1852
1852
 
1853
+ for (const [key, val] of Object.entries(data?.profiles || {})) {
1854
+ }
1855
+
1853
1856
  return { code: 55, data };
1854
1857
  } catch (err) {
1855
1858
  return { code: -55, data: err.message };
@@ -3303,6 +3306,8 @@ export const find_contact_query = async function (uid, opt) {
3303
3306
  return ret;
3304
3307
  };
3305
3308
 
3309
+ //////////////////////////////
3310
+
3306
3311
  export const delete_xuda_cache = async function (contact_obj) {
3307
3312
  const ret = await db_module.find_couch_query('xuda_cache', {
3308
3313
  selector: {
@@ -3373,6 +3378,8 @@ export const save_cache_hit = async function (_id) {
3373
3378
  }
3374
3379
  };
3375
3380
 
3381
+ ///////////////////////////////
3382
+
3376
3383
  export const record_ai_usage = async function (uid, input_tokens, output_tokens, source, prompt, model, metadata = {}, account_profile_info, tools) {
3377
3384
  try {
3378
3385
  if (!account_profile_info) throw new Error('missing account_profile_info');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/account_module",
3
- "version": "1.2.2093",
3
+ "version": "1.2.2095",
4
4
  "description": "Xuda Account Server Module",
5
5
  "main": "index.mjs",
6
6
  "dependencies": {