@xuda.io/ai_module 1.1.4140 → 1.1.4141

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 +6 -4
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -4150,7 +4150,7 @@ export const delete_prompt_attachment = async function (req, job_id, headers, fi
4150
4150
  };
4151
4151
 
4152
4152
  export const submit_chat_gpt_prompt = async function (req) {
4153
- const { model = 'gpt-5-nano', prompt, response_format, uid, metadata = {} } = req; //'gpt-5-mini
4153
+ const { model = 'gpt-5-nano', prompt, response_format, uid, metadata = {}, account_profile_info } = req; //'gpt-5-mini
4154
4154
 
4155
4155
  let formattedParams;
4156
4156
  if (response_format) {
@@ -4165,7 +4165,7 @@ export const submit_chat_gpt_prompt = async function (req) {
4165
4165
  format: formattedParams,
4166
4166
  },
4167
4167
  });
4168
- record_chat_usage(uid, response.usage.input_tokens, response.usage.output_tokens, 'submit chat', prompt, model, metadata);
4168
+ record_chat_usage(uid, response.usage.input_tokens, response.usage.output_tokens, 'submit chat', prompt, model, metadata, account_profile_info);
4169
4169
  return { code: 5, data: response.output_text };
4170
4170
  } catch (err) {
4171
4171
  return { code: -5, data: err.message };
@@ -6310,8 +6310,9 @@ const create_ai_agent_image = async function (req, job_id, headers) {
6310
6310
  }
6311
6311
  };
6312
6312
 
6313
- const record_chat_usage = async function (uid, input_tokens, output_tokens, source, prompt, model, metadata = {}) {
6313
+ const record_chat_usage = async function (uid, input_tokens, output_tokens, source, prompt, model, metadata = {}, account_profile_info) {
6314
6314
  try {
6315
+ if (!account_profile_info) throw new Error('missing account_profile_info');
6315
6316
  const app_id = await account_module.get_account_default_project_id(uid);
6316
6317
 
6317
6318
  const cost = _conf?.ai_models?.[model] || {
@@ -6333,8 +6334,9 @@ const record_chat_usage = async function (uid, input_tokens, output_tokens, sour
6333
6334
  metadata,
6334
6335
  model,
6335
6336
  cost,
6337
+ account_profile_info,
6336
6338
  };
6337
- const save_ret = await db_module.save_app_couch_doc(app_id, usage_doc);
6339
+ const save_ret = await db_module.save_app_couch_doc(account_profile_info.app_id, usage_doc);
6338
6340
  // console.log(save_ret);
6339
6341
  } catch (err) {
6340
6342
  console.error(err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.4140",
3
+ "version": "1.1.4141",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",