Fixed the buttons

This commit is contained in:
Patrick_Pluto 2024-09-24 16:42:36 +02:00
parent 19a9567a5d
commit bb3db0ce1c
6 changed files with 103 additions and 164 deletions

View file

@ -3,8 +3,8 @@ import axios from "axios";
let accesstoken
onmessage = (event) => {
const { action, access_token } = event.data
accesstoken=access_token
accesstoken = access_token
if (action === "start") {
fetchData()
} else if (action === "terminate") {
@ -15,20 +15,20 @@ console.log('starting get loop');
const fetchData = () => {
console.log(accesstoken);
const apiURL = "http://localhost:5000/interstellar/api/ai_get?access_token="+accesstoken
const apiURL = "http://localhost:5000/interstellar_ai/api/ai_get?access_token=" + accesstoken
axios.get(apiURL)
.then(response => {
const data = response.data
console.log(data);
postMessage(data)
setTimeout(fetchData,100)
setTimeout(fetchData, 100)
})
.catch(error => {
console.log('Error fetching data:', error);
postMessage({error:"failed fetching data"})
setTimeout(() => fetchData(),1000)
})
postMessage({ error: "failed fetching data" })
setTimeout(() => fetchData(), 1000)
})
}

View file

@ -7,23 +7,23 @@ onmessage = (e) => {
const Message = {
messages: messages,
ai_model: "phi3.5",
model_type:"local",
access_token:access_token
model_type: "local",
access_token: access_token
}
console.log(Message);
axios.post("http://localhost:5000/interstellar/api/ai_send",Message)
axios.post("http://localhost:5000/interstellar_ai/api/ai_send", Message)
.then(response => {
const status = response.data.status
console.log(status);
postMessage({ status })
console.log('message posted');
})
.catch(error => {
console.log("Error calling API:", error)
postMessage({status:500})
})
postMessage({ status: 500 })
})
}