interstellar_ai/app/backend/threads/PostWorker.js

29 lines
No EOL
712 B
JavaScript

import axios from "axios";
onmessage = (e) => {
const { messages, ai_model = "llama3.2", access_token } = e.data
const Message = {
messages: messages,
ai_model: "llama3.2",
model_type: "local",
access_token: access_token
}
console.log(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 })
})
}