| const keywords = { | |
| image:[ | |
| "draw","image","picture","paint","generate image","photo" | |
| ], | |
| translation:[ | |
| "translate","translation","convert language" | |
| ], | |
| summary:[ | |
| "summarize","summary","shorten" | |
| ], | |
| caption:[ | |
| "describe image","caption" | |
| ] | |
| }; | |
| function detectTask(prompt){ | |
| prompt = prompt.toLowerCase(); | |
| for(let task in keywords){ | |
| for(let word of keywords[task]){ | |
| if(prompt.includes(word)){ | |
| return task; | |
| } | |
| } | |
| } | |
| return "text"; | |
| } |