Started changes the file structure

This commit is contained in:
sageTheDM 2024-09-20 10:34:16 +02:00
parent 464df4adac
commit 89b3b824c7
17 changed files with 12 additions and 12 deletions

39
app/backend/ProcessAPI.js Normal file
View file

@ -0,0 +1,39 @@
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://127.0.0.1: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://127.0.0.1:5000/interstellar/api/ai_send', data)
.then(Response => {
postMessage(Response.data)
}).catch(error => {
console.error("Error:", error)
})
break
case "getResponse":
axios.get('https://127.0.0.1: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
}
}