@xuda.io/ai_module 1.1.3952 → 1.1.3955

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 +14 -8
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -2449,15 +2449,15 @@ export const get_ai_agents = async function (req, job_id, headers) {
2449
2449
  user_agents = await db_module.find_app_couch_query(app_id, opt);
2450
2450
  if (!limit || ai_agent_id) {
2451
2451
  user_agents.total_docs = user_agents.docs.length;
2452
- }
2453
- else {
2454
- delete opt.sort;
2455
- delete opt.skip;
2456
- opt.limit = 9999;
2457
- opt.fields = ['_id'];
2452
+ } else {
2453
+ delete opt.sort;
2454
+ delete opt.skip;
2455
+ opt.limit = 9999;
2456
+ opt.fields = ['_id'];
2458
2457
 
2459
- const counter = await db_module.find_app_couch_query(app_id, opt);
2460
- user_agents.total_docs = counter.docs.length;
2458
+ const counter = await db_module.find_app_couch_query(app_id, opt);
2459
+ user_agents.total_docs = counter.docs.length;
2460
+ }
2461
2461
  }
2462
2462
 
2463
2463
  ////// FROM - IN
@@ -6370,6 +6370,11 @@ const record_chat_usage = async function (uid, input_tokens, output_tokens, sour
6370
6370
  try {
6371
6371
  const app_id = await account_module.get_account_default_project_id(uid);
6372
6372
 
6373
+ const cost = _conf?.ai_models?.[model] || {
6374
+ input: 1.0,
6375
+ output: 1.0,
6376
+ };
6377
+
6373
6378
  const t = Date.now();
6374
6379
  let usage_doc = {
6375
6380
  _id: await _common.xuda_get_uuid('chat_usage'),
@@ -6383,6 +6388,7 @@ const record_chat_usage = async function (uid, input_tokens, output_tokens, sour
6383
6388
  stat: 3,
6384
6389
  metadata,
6385
6390
  model,
6391
+ cost,
6386
6392
  };
6387
6393
  const save_ret = await db_module.save_app_couch_doc(app_id, usage_doc);
6388
6394
  // console.log(save_ret);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.3952",
3
+ "version": "1.1.3955",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",