live message! (limit:1)

This commit is contained in:
YasinOnm08 2024-09-23 16:34:55 +02:00
parent 2fc501d2bf
commit 8cc191dad1
3 changed files with 39 additions and 15 deletions

View file

@ -1,23 +1,23 @@
import axios from "axios";
let shouldRun = false
let accesstoken
onmessage = (event) => {
const { action, access_token } = event.data
accesstoken=access_token
if (action === "start") {
shouldRun = true
fetchData(access_token)
fetchData()
} else if (action === "terminate") {
shouldRun = false
}
}
console.log('starting get loop');
const fetchData = (access_token) => {
if (!shouldRun) return
const fetchData = () => {
console.log(accesstoken);
const apiURL = "http://localhost:5000/interstellar/api/ai_get?access_token="+access_token
const apiURL = "http://localhost:5000/interstellar/api/ai_get?access_token="+accesstoken
axios.get(apiURL)
.then(response => {

View file

@ -2,17 +2,18 @@ import axios from "axios";
onmessage = (e) => {
const { messages = [{ role: "assistant", content: "Hello! How can I help you?" }], ai_model = "phi3.5", access_token } = e.data
const promptedMessage = messages.unshift({role:"system", content:"You are a Helpful assistant"})
messages.unshift({ role: "system", content: "You are a Helpful assistant" })
const Message = {
messages: promptedMessage,
messages: messages,
ai_model: "phi3.5",
model_type:"local",
access_token:access_token
}
console.log(Message);
axios.post("http://localhost:5000/interstellar/api/ai_send",Message)
.then(response => {
const status = response.data.status