forked from React-Group/interstellar_ai
multithread implementation
This commit is contained in:
parent
fe2bfa60ce
commit
3f8841a630
5 changed files with 99 additions and 40 deletions
|
@ -2,23 +2,23 @@ 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
|
||||
const data = {
|
||||
"ai_model": ai_model,
|
||||
"message": message,
|
||||
"system_prompt": system_prompt,
|
||||
"access_token": access_token
|
||||
};
|
||||
switch (functionName) {
|
||||
case "getAccess":
|
||||
axios.get('http://localhost:5000/interstellar/api/ai_create')
|
||||
.then(Response => {
|
||||
axios.get('https://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)
|
||||
axios.post('https://localhost:5000/interstellar/api/ai_send', data)
|
||||
.then(Response => {
|
||||
postMessage(Response.data)
|
||||
}).catch(error => {
|
||||
|
@ -26,7 +26,7 @@ onmessage = function (e) {
|
|||
})
|
||||
break
|
||||
case "getResponse":
|
||||
axios.get('http://localhost:5000/interstellar/api/ai_get')
|
||||
axios.get('https://localhost:5000/interstellar/api/ai_get?access_token='+access_token)
|
||||
.then(Response => {
|
||||
postMessage(Response.data.response)
|
||||
}).catch(error => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue