I'm not using any frameworks, I have a small repo with no actual errors
the files I said about look like this and I have used them in other places
1//--ai.js--//2const tokens = (i) => {3 let t = 0;4 for (const m of i) {5 t += m.content.split(" ").length;6 }7 return t;8};9const limit_tokens = (i,x) => {10 let t = 0;11 let l = [];12 for (let n=i.length-1;n>=0;n--) {13 const m = i[n];14 const c = m.content.split(" ").length;15 if (t+c<=x) {16 l.unshift(m);17 t += c;18 } else {19 l.unshift({ ...m , content: m.content.split(" ").slice(-x+t).join(" ") });20 break;21 }22 }23 return l;24};25const groq_gen = async (messages,model="gemma2-9b-it",temperature=1,top_p=1,max_completion_tokens=1024) => {26 const res = await fetch("https://api.groq.com/openai/v1/chat/completions",{27 method: "POST",28 headers: {29 "Content-Type": "application/json",30 "Authorization": "Bearer ******"31 },32 body: JSON.stringify({33 messages,34 model,35 temperature,36 top_p,37 max_completion_tokens,38 stop: null39 })40 });41 return await res.json();42};43module.exports = {44 tokens,45 limit_tokens,46 groq_gen47}