2024-09-23 11:11:45 +02:00
|
|
|
import axios from "axios";
|
|
|
|
|
|
|
|
onmessage = (e) => {
|
2024-09-30 15:26:31 +02:00
|
|
|
const { messages, ai_model, model_type, access_token, api_key } = e.data
|
|
|
|
|
2024-09-23 14:54:13 +02:00
|
|
|
|
|
|
|
const Message = {
|
2024-09-23 16:34:55 +02:00
|
|
|
messages: messages,
|
2024-09-30 15:26:31 +02:00
|
|
|
ai_model: ai_model,
|
|
|
|
model_type: model_type,
|
|
|
|
access_token: access_token,
|
|
|
|
api_key: api_key
|
2024-09-23 14:54:13 +02:00
|
|
|
}
|
|
|
|
|
2024-09-24 16:42:36 +02:00
|
|
|
axios.post("http://localhost:5000/interstellar_ai/api/ai_send", Message)
|
2024-09-23 11:11:45 +02:00
|
|
|
.then(response => {
|
|
|
|
const status = response.data.status
|
2024-09-23 14:54:13 +02:00
|
|
|
postMessage({ status })
|
2024-09-24 16:42:36 +02:00
|
|
|
|
2024-09-23 11:11:45 +02:00
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
console.log("Error calling API:", error)
|
2024-09-24 16:42:36 +02:00
|
|
|
postMessage({ status: 500 })
|
|
|
|
})
|
2024-09-23 11:11:45 +02:00
|
|
|
}
|