forked from React-Group/interstellar_ai
started multithreading
This commit is contained in:
parent
ef2e40ca4a
commit
024ceeda4e
5 changed files with 103 additions and 2 deletions
39
app/ProcessAPI.js
Normal file
39
app/ProcessAPI.js
Normal file
|
@ -0,0 +1,39 @@
|
|||
import axios from 'axios'
|
||||
|
||||
onmessage = function (e) {
|
||||
const { functionName = "getAccess", access_token = "", message = "", ai_model = "phi3.5", system_prompt = "You are a helpful assistant" } = e.data
|
||||
switch (functionName) {
|
||||
case "getAccess":
|
||||
axios.get('http://localhost:5000/interstellar/api/ai_create')
|
||||
.then(Response => {
|
||||
postMessage(Response.data.access_token)
|
||||
}).catch(error => {
|
||||
console.error("Error with GET Token request:", error)
|
||||
})
|
||||
break
|
||||
case "postRequest":
|
||||
const data = {
|
||||
ai_model: ai_model,
|
||||
message: message,
|
||||
system_prompt: system_prompt,
|
||||
access_token: access_token
|
||||
};
|
||||
axios.post('http://localhost:5000/interstellar/api/ai_send', data)
|
||||
.then(Response => {
|
||||
postMessage(Response.data)
|
||||
}).catch(error => {
|
||||
console.error("Error:", error)
|
||||
})
|
||||
break
|
||||
case "getResponse":
|
||||
axios.get('http://localhost:5000/interstellar/api/ai_get')
|
||||
.then(Response => {
|
||||
postMessage(Response.data.response)
|
||||
}).catch(error => {
|
||||
console.error("Error with GET response request:", error)
|
||||
})
|
||||
break
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue