@xuda.io/ai_module 1.1.4170 → 1.1.4172

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 -10
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -2945,7 +2945,7 @@ export const get_apps = async function (req, job_id, headers) {
2945
2945
  // };
2946
2946
 
2947
2947
  const upload_agent_files = async function (uid, agent_doc) {
2948
- let { agentConfig } = agent_doc;
2948
+ let { agentConfig, account_profile_info } = agent_doc;
2949
2949
  for await (let tool of agentConfig.agent_tools || []) {
2950
2950
  if (tool.type === 'file_search') {
2951
2951
  if (!_.isEmpty(tool.file)) {
@@ -2961,8 +2961,8 @@ const upload_agent_files = async function (uid, agent_doc) {
2961
2961
  case 'audio':
2962
2962
  case 'video': {
2963
2963
  await save_agent_status(uid, agent_doc._id, 2, agentConfig);
2964
- const file_stream = await get_drive_file_stream('user', agent_doc.account_profile_info.app_id, uid, tool.file.name);
2965
- const transcript = await transcribe(uid, file_stream, { agent_id: agent_doc._id, func: 'upload_agent_files -' + validation_ret.category });
2964
+ const file_stream = await get_drive_file_stream('user', account_profile_info.app_id, uid, tool.file.name);
2965
+ const transcript = await transcribe(uid, file_stream, { agent_id: agent_doc._id, func: 'upload_agent_files -' + validation_ret.category }, account_profile_info);
2966
2966
 
2967
2967
  file = new File([Buffer.from(transcript, 'utf8')], tool.file.name, {
2968
2968
  type: 'text/plain',
@@ -2980,7 +2980,7 @@ const upload_agent_files = async function (uid, agent_doc) {
2980
2980
  }
2981
2981
 
2982
2982
  case 'image': {
2983
- const response = await get_drive_file_response('user', agent_doc.account_profile_info.app_id, uid, tool.file.name);
2983
+ const response = await get_drive_file_response('user', account_profile_info.app_id, uid, tool.file.name);
2984
2984
 
2985
2985
  if (!response.ok) throw new Error(`Failed to download file: ${response.statusText}`);
2986
2986
  const arrayBuffer = await response.arrayBuffer();
@@ -3017,7 +3017,7 @@ const upload_agent_files = async function (uid, agent_doc) {
3017
3017
 
3018
3018
  case 'document':
3019
3019
  case 'text': {
3020
- file = await get_drive_file_stream('user', agent_doc.account_profile_info.app_id, uid, tool.file.name);
3020
+ file = await get_drive_file_stream('user', account_profile_info.app_id, uid, tool.file.name);
3021
3021
  // tool.file.file_id = await upload_file_to_openai_storage(tool.file.name);
3022
3022
  break;
3023
3023
  }
@@ -3475,7 +3475,7 @@ const get_drive_file_stream = async function (drive_type, app_id, uid, file_path
3475
3475
  }
3476
3476
  };
3477
3477
 
3478
- const transcribe = async function (uid, stream, metadata) {
3478
+ const transcribe = async function (uid, stream, metadata, account_profile_info) {
3479
3479
  try {
3480
3480
  const model = 'whisper-1';
3481
3481
  const resp = await client.audio.transcriptions.create({
@@ -4422,7 +4422,7 @@ const chat_note = async function (req, job_id, headers) {
4422
4422
  const sender_app_id = conversation_doc.account_profile_info.app_id; //await account_module.get_account_default_project_id(uid);
4423
4423
  let sender_conversation_doc = await db_module.get_app_couch_doc_native(sender_app_id, conversation_id);
4424
4424
 
4425
- await attachment_handler(uid, sender_app_id, conversation_id, attachments);
4425
+ await attachment_handler(uid, sender_app_id, conversation_id, attachments, account_profile_info);
4426
4426
 
4427
4427
  const item = await client.conversations.items.create(conversation_id, {
4428
4428
  items: [
@@ -5016,7 +5016,7 @@ const ai_chat_conversation = async function (req, job_id, headers) {
5016
5016
  /////////////
5017
5017
  if (attachments?.length) {
5018
5018
  await update_job('analyzing attachments');
5019
- await attachment_handler(uid, app_id, conversation_id, attachments);
5019
+ await attachment_handler(uid, app_id, conversation_id, attachments, account_profile_info);
5020
5020
  }
5021
5021
  ////////////
5022
5022
 
@@ -6402,7 +6402,7 @@ export const unpin_ai_agent = async function (req, job_id, headers) {
6402
6402
  }
6403
6403
  };
6404
6404
 
6405
- const attachment_handler = async function (uid, app_id, conversation_id, attachments) {
6405
+ const attachment_handler = async function (uid, app_id, conversation_id, attachments, account_profile_info) {
6406
6406
  if (!attachments?.length) return;
6407
6407
 
6408
6408
  const get_transcript = async function (filename) {
@@ -6425,7 +6425,7 @@ const attachment_handler = async function (uid, app_id, conversation_id, attachm
6425
6425
  switch (validation_ret.category) {
6426
6426
  case 'audio':
6427
6427
  case 'video': {
6428
- transcript = await transcribe(uid, fileStream, { conversation_id, func: 'attachment_handler - ' + validation_ret.category });
6428
+ transcript = await transcribe(uid, fileStream, { conversation_id, func: 'attachment_handler - ' + validation_ret.category }, account_profile_info);
6429
6429
 
6430
6430
  break;
6431
6431
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.4170",
3
+ "version": "1.1.4172",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",