import axios from 'axios' onmessage = function (e) { const { functionName = "getAccess", access_token = "", message = "", ai_model = "phi3.5", system_prompt = "You are a helpful assistant" } = e.data const data = { "ai_model": ai_model, "message": message, "system_prompt": system_prompt, "access_token": access_token }; switch (functionName) { case "getAccess": axios.get('https://localhost:5000/interstellar/api/ai_create') .then(Response => { postMessage(Response.data.access_token) }).catch(error => { console.error("Error with GET Token request:", error) }) break case "postRequest": axios.post('https://localhost:5000/interstellar/api/ai_send', data) .then(Response => { postMessage(Response.data) }).catch(error => { console.error("Error:", error) }) break case "getResponse": axios.get('https://localhost:5000/interstellar/api/ai_get?access_token='+access_token) .then(Response => { postMessage(Response.data.response) }).catch(error => { console.error("Error with GET response request:", error) }) break } }