Create router.js
Browse files
router.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const keywords = {
|
| 2 |
+
|
| 3 |
+
image:[
|
| 4 |
+
"draw","image","picture","paint","generate image","photo"
|
| 5 |
+
],
|
| 6 |
+
|
| 7 |
+
translation:[
|
| 8 |
+
"translate","translation","convert language"
|
| 9 |
+
],
|
| 10 |
+
|
| 11 |
+
summary:[
|
| 12 |
+
"summarize","summary","shorten"
|
| 13 |
+
],
|
| 14 |
+
|
| 15 |
+
caption:[
|
| 16 |
+
"describe image","caption"
|
| 17 |
+
]
|
| 18 |
+
|
| 19 |
+
};
|
| 20 |
+
|
| 21 |
+
function detectTask(prompt){
|
| 22 |
+
|
| 23 |
+
prompt = prompt.toLowerCase();
|
| 24 |
+
|
| 25 |
+
for(let task in keywords){
|
| 26 |
+
|
| 27 |
+
for(let word of keywords[task]){
|
| 28 |
+
|
| 29 |
+
if(prompt.includes(word)){
|
| 30 |
+
|
| 31 |
+
return task;
|
| 32 |
+
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
return "text";
|
| 40 |
+
|
| 41 |
+
}
|