multithread trial 3

This commit is contained in:
YasinOnm08 2024-09-23 14:54:13 +02:00
parent 5ff6913426
commit f587864d3c
3 changed files with 37 additions and 16 deletions

View file

@ -1,12 +1,25 @@
import axios from "axios";
onmessage = (e) => {
const { messages = [{ role: "system", content: "You are a helpful assistant" }], ai_model = "phi3.5", access_token } = e.data
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"})
const Message = {
messages: promptedMessage,
ai_model: "phi3.5",
model_type:"local",
access_token:access_token
}
axios.post("http://localhost:5000/interstellar/api/ai_send")
axios.post("http://localhost:5000/interstellar/api/ai_send",Message)
.then(response => {
const status = response.data.status
postMessage({status})
console.log(status);
postMessage({ status })
console.log('message posted');
})
.catch(error => {
console.log("Error calling API:", error)