convo with new prompts

This commit is contained in:
YasinOnm08 2024-09-20 09:17:28 +02:00
parent ce635d3089
commit e279f01d42
3 changed files with 59 additions and 44 deletions

View file

@ -1,32 +1,39 @@
import axios from 'axios'
import { type } from 'os';
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
const { functionName = "getAccess", access_token = "", messages = [], ai_model = "phi3.5", system_prompt = {role:"system" ,content: "You are a helpful assistant that gives short answers"}} = e.data
let data = {
ai_model: ai_model,
messages: messages,
access_token: access_token
};
console.log(messages)
switch (functionName) {
case "getAccess":
axios.get('https://127.0.0.1:5000/interstellar/api/ai_create')
.then(Response => {
postMessage(Response.data.access_token)
}).catch(error => {
console.error("Error with GET Token request:", error)
})
console.log("getting access...")
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":
axios.post('https://127.0.0.1:5000/interstellar/api/ai_send', data)
.then(Response => {
postMessage(Response.data)
}).catch(error => {
console.error("Error:", error)
})
messages.unshift(system_prompt)
console.log("sending...")
console.log(messages)
axios.post('https://localhost:5000/interstellar/api/ai_send', data)
.then(Response => {
postMessage(Response.data)
}).catch(error => {
console.error("Error:", error)
})
break
case "getResponse":
axios.get('https://127.0.0.1:5000/interstellar/api/ai_get?access_token=' + access_token)
axios.get('https://localhost:5000/interstellar/api/ai_get?access_token=' + access_token)
.then(Response => {
postMessage(Response.data.response)
}).catch(error => {