forked from React-Group/interstellar_ai
OMG FINALY WORKING LIVE TEXT
This commit is contained in:
parent
d037439b4c
commit
37177a7856
3 changed files with 6 additions and 2 deletions
|
@ -90,11 +90,15 @@ const InputOutputBackend: React.FC = () => {
|
||||||
if (getWorkerRef.current) {
|
if (getWorkerRef.current) {
|
||||||
getWorkerRef.current.postMessage({action:"terminate"})
|
getWorkerRef.current.postMessage({action:"terminate"})
|
||||||
getWorkerRef.current.terminate()
|
getWorkerRef.current.terminate()
|
||||||
|
getWorkerRef.current = null
|
||||||
console.log(messages);
|
console.log(messages);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const editLastMessage = (newContent: string) => {
|
const editLastMessage = (newContent: string) => {
|
||||||
|
if (newContent == "") {
|
||||||
|
newContent = "Loading..."
|
||||||
|
}
|
||||||
setMessages((prevMessages) => {
|
setMessages((prevMessages) => {
|
||||||
const updatedMessages = prevMessages.slice(); // Create a shallow copy of the current messages
|
const updatedMessages = prevMessages.slice(); // Create a shallow copy of the current messages
|
||||||
if (updatedMessages.length > 0) {
|
if (updatedMessages.length > 0) {
|
||||||
|
|
|
@ -29,6 +29,6 @@ const fetchData = () => {
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.log('Error fetching data:', error);
|
console.log('Error fetching data:', error);
|
||||||
postMessage({error:"failed fetching data"})
|
postMessage({error:"failed fetching data"})
|
||||||
|
setTimeout(() => fetchData(),1000)
|
||||||
})
|
})
|
||||||
}
|
}
|
|
@ -2,7 +2,7 @@ import axios from "axios";
|
||||||
|
|
||||||
onmessage = (e) => {
|
onmessage = (e) => {
|
||||||
const { messages = [{ role: "assistant", content: "Hello! How can I help you?" }], 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
|
||||||
messages.unshift({ role: "system", content: "You are a Helpful assistant" })
|
messages.unshift({ role: "system", content: "You are a Helpful assistant. you give short answers" })
|
||||||
|
|
||||||
const Message = {
|
const Message = {
|
||||||
messages: messages,
|
messages: messages,
|
||||||
|
|
Loading…
Reference in a new issue