@xuda.io/ai_module 1.1.4169 → 1.1.4171
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 +8 -8
- 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',
|
|
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',
|
|
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',
|
|
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({
|
|
@@ -3486,7 +3486,7 @@ const transcribe = async function (uid, stream, metadata) {
|
|
|
3486
3486
|
language: 'en', // hint language (ISO 639-1), e.g. "he" for Hebrew
|
|
3487
3487
|
// temperature: 0 // lower = more literal
|
|
3488
3488
|
});
|
|
3489
|
-
record_chat_usage(uid, 0, resp.length || 0, 'transcribe', '', model, metadata);
|
|
3489
|
+
record_chat_usage(uid, 0, resp.length || 0, 'transcribe', '', model, metadata, account_profile_info);
|
|
3490
3490
|
console.log(resp); // or resp for JSON formats
|
|
3491
3491
|
return resp;
|
|
3492
3492
|
} catch (error) {
|
|
@@ -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
|
}
|