-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcallGemini.js
More file actions
20 lines (19 loc) · 949 Bytes
/
Copy pathcallGemini.js
File metadata and controls
20 lines (19 loc) · 949 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import mime from 'mime-types'
import predictFolder from './ai.js';
import chalk from 'chalk';
import moveFile from './moveFile.js';
export default async function callGemini(change, path) {
const mimeType = mime.lookup(path)
console.log(`\nFile ${path} has been ${change}ed\nMime type : ${mimeType}`);
if (change === 'add' || change === 'chang') {
const result = await predictFolder(mimeType, path);
if (result.status === 'success'){
// console.log(`Prediction data ${result.data}`);
const {folder, confidence, suggestedName, reason} = JSON.parse(result.data);
console.log((`Suggested folder name ${folder} and file name ${suggestedName} with confidence ${confidence}\nReasoning:${reason}`));
await moveFile(confidence, path, folder, suggestedName);
}
else
console.log(chalk.red(`Invalid file type : ${result.data}`));
}
}