mirror of
https://github.com/ParisNeo/lollms-webui.git
synced 2025-02-06 10:59:23 +00:00
upgraded
This commit is contained in:
parent
967b9dc416
commit
d1fbf77d0d
@ -34,15 +34,16 @@ import ctypes
|
|||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
def terminate_thread(thread):
|
def terminate_thread(thread):
|
||||||
if not thread.is_alive():
|
if thread:
|
||||||
return
|
if not thread.is_alive():
|
||||||
|
return
|
||||||
|
|
||||||
thread_id = thread.ident
|
thread_id = thread.ident
|
||||||
exc = ctypes.py_object(SystemExit)
|
exc = ctypes.py_object(SystemExit)
|
||||||
res = ctypes.pythonapi.PyThreadState_SetAsyncExc(thread_id, exc)
|
res = ctypes.pythonapi.PyThreadState_SetAsyncExc(thread_id, exc)
|
||||||
if res > 1:
|
if res > 1:
|
||||||
ctypes.pythonapi.PyThreadState_SetAsyncExc(thread_id, None)
|
ctypes.pythonapi.PyThreadState_SetAsyncExc(thread_id, None)
|
||||||
raise SystemError("Failed to terminate the thread.")
|
raise SystemError("Failed to terminate the thread.")
|
||||||
|
|
||||||
__author__ = "parisneo"
|
__author__ = "parisneo"
|
||||||
__github__ = "https://github.com/ParisNeo/lollms-webui"
|
__github__ = "https://github.com/ParisNeo/lollms-webui"
|
||||||
@ -150,7 +151,9 @@ class LoLLMsAPPI(LollmsApplication):
|
|||||||
"current_discussion":None,
|
"current_discussion":None,
|
||||||
"generated_text":"",
|
"generated_text":"",
|
||||||
"cancel_generation": False,
|
"cancel_generation": False,
|
||||||
"generation_thread": None
|
"generation_thread": None,
|
||||||
|
"current_discussion":None,
|
||||||
|
"current_message_id":0
|
||||||
}
|
}
|
||||||
ASCIIColors.success(f'Client {request.sid} connected')
|
ASCIIColors.success(f'Client {request.sid} connected')
|
||||||
|
|
||||||
@ -389,6 +392,7 @@ class LoLLMsAPPI(LollmsApplication):
|
|||||||
self.connections[client_id]["generated_text"]=""
|
self.connections[client_id]["generated_text"]=""
|
||||||
self.connections[client_id]["cancel_generation"]=False
|
self.connections[client_id]["cancel_generation"]=False
|
||||||
|
|
||||||
|
|
||||||
if self.is_ready:
|
if self.is_ready:
|
||||||
if self.current_discussion is None:
|
if self.current_discussion is None:
|
||||||
if self.db.does_last_discussion_have_messages():
|
if self.db.does_last_discussion_have_messages():
|
||||||
@ -441,7 +445,11 @@ class LoLLMsAPPI(LollmsApplication):
|
|||||||
def handle_connection(data):
|
def handle_connection(data):
|
||||||
client_id = request.sid
|
client_id = request.sid
|
||||||
message_id = int(data['id'])
|
message_id = int(data['id'])
|
||||||
message = data["prompt"]
|
if message_id==-1:
|
||||||
|
message_id = self.message_id
|
||||||
|
message = ""
|
||||||
|
else:
|
||||||
|
message = data["prompt"]
|
||||||
self.current_user_message_id = message_id
|
self.current_user_message_id = message_id
|
||||||
self.connections[client_id]['generation_thread'] = threading.Thread(target=self.start_message_generation, args=(message, message_id, client_id))
|
self.connections[client_id]['generation_thread'] = threading.Thread(target=self.start_message_generation, args=(message, message_id, client_id))
|
||||||
self.connections[client_id]['generation_thread'].start()
|
self.connections[client_id]['generation_thread'].start()
|
||||||
@ -786,9 +794,7 @@ class LoLLMsAPPI(LollmsApplication):
|
|||||||
if self.personality.processor is not None:
|
if self.personality.processor is not None:
|
||||||
ASCIIColors.success("Running workflow")
|
ASCIIColors.success("Running workflow")
|
||||||
try:
|
try:
|
||||||
output = self.personality.processor.run_workflow( prompt, full_prompt, callback)
|
self.personality.processor.run_workflow( prompt, full_prompt, callback)
|
||||||
if callback:
|
|
||||||
callback(output, MSG_TYPE.MSG_TYPE_FULL)
|
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
# Catch the exception and get the traceback as a list of strings
|
# Catch the exception and get the traceback as a list of strings
|
||||||
traceback_lines = traceback.format_exception(type(ex), ex, ex.__traceback__)
|
traceback_lines = traceback.format_exception(type(ex), ex, ex.__traceback__)
|
||||||
|
@ -100,8 +100,11 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="showPersonalities" class="mx-1">
|
<div v-if="showPersonalities" class="mx-1">
|
||||||
<MountedPersonalitiesList ref="mountedPersList" :onShowPersList="onShowPersListFun"
|
<MountedPersonalitiesList ref="mountedPersList"
|
||||||
:on-mount-unmount="onMountUnmountFun" :discussionPersonalities="allDiscussionPersonalities" />
|
:onShowPersList="onShowPersListFun"
|
||||||
|
:on-mount-unmount="onMountUnmountFun"
|
||||||
|
:on-talk="handleOnTalk"
|
||||||
|
:discussionPersonalities="allDiscussionPersonalities" />
|
||||||
</div>
|
</div>
|
||||||
<!-- CHAT BOX -->
|
<!-- CHAT BOX -->
|
||||||
<div class="flex flex-row flex-grow items-center gap-2 overflow-visible">
|
<div class="flex flex-row flex-grow items-center gap-2 overflow-visible">
|
||||||
@ -114,6 +117,7 @@
|
|||||||
v-if="personalities_ready && this.$store.state.mountedPersArr[this.$store.state.config.active_personality_id].commands!=''"
|
v-if="personalities_ready && this.$store.state.mountedPersArr[this.$store.state.config.active_personality_id].commands!=''"
|
||||||
:commandsList="this.$store.state.mountedPersArr[this.$store.state.config.active_personality_id].commands"
|
:commandsList="this.$store.state.mountedPersArr[this.$store.state.config.active_personality_id].commands"
|
||||||
:sendCommand="sendMessageEvent"
|
:sendCommand="sendMessageEvent"
|
||||||
|
:on-show-toast-message="onShowToastMessage"
|
||||||
ref="personalityCMD"
|
ref="personalityCMD"
|
||||||
></PersonalitiesCommands>
|
></PersonalitiesCommands>
|
||||||
</div>
|
</div>
|
||||||
@ -206,8 +210,10 @@ export default {
|
|||||||
name: 'ChatBox',
|
name: 'ChatBox',
|
||||||
emits: ["messageSentEvent", "stopGenerating"],
|
emits: ["messageSentEvent", "stopGenerating"],
|
||||||
props: {
|
props: {
|
||||||
|
onTalk: Function,
|
||||||
discussionList: Array,
|
discussionList: Array,
|
||||||
loading: false
|
loading: false,
|
||||||
|
onShowToastMessage: Function
|
||||||
|
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
@ -255,6 +261,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
||||||
onPersonalitiesReadyFun(){
|
onPersonalitiesReadyFun(){
|
||||||
this.personalities_ready = true;
|
this.personalities_ready = true;
|
||||||
},
|
},
|
||||||
@ -262,6 +269,11 @@ export default {
|
|||||||
this.showPersonalities = !this.showPersonalities
|
this.showPersonalities = !this.showPersonalities
|
||||||
|
|
||||||
},
|
},
|
||||||
|
handleOnTalk(pers){
|
||||||
|
this.showPersonalities=false
|
||||||
|
this.onTalk(pers)
|
||||||
|
},
|
||||||
|
|
||||||
onMountUnmountFun(comp) {
|
onMountUnmountFun(comp) {
|
||||||
console.log('Mounting/unmounting chat')
|
console.log('Mounting/unmounting chat')
|
||||||
this.$refs.mountedPers.constructor()
|
this.$refs.mountedPers.constructor()
|
||||||
|
@ -39,7 +39,9 @@
|
|||||||
:key="'index-' + index + '-' + pers.name" :personality="pers" :full_path="pers.full_path"
|
:key="'index-' + index + '-' + pers.name" :personality="pers" :full_path="pers.full_path"
|
||||||
:selected="configFile.personalities[configFile.active_personality_id] === pers.full_path"
|
:selected="configFile.personalities[configFile.active_personality_id] === pers.full_path"
|
||||||
:on-selected="onPersonalitySelected" :on-mounted="onPersonalityMounted"
|
:on-selected="onPersonalitySelected" :on-mounted="onPersonalityMounted"
|
||||||
:on-settings="onSettingsPersonality" :on-reinstall="onPersonalityReinstall"/>
|
:on-settings="onSettingsPersonality" :on-reinstall="onPersonalityReinstall"
|
||||||
|
:on-talk="handleOnTalk"
|
||||||
|
/>
|
||||||
</TransitionGroup>
|
</TransitionGroup>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -87,6 +89,7 @@ const bUrl = import.meta.env.VITE_GPT4ALL_API_BASEURL
|
|||||||
axios.defaults.baseURL = import.meta.env.VITE_GPT4ALL_API_BASEURL
|
axios.defaults.baseURL = import.meta.env.VITE_GPT4ALL_API_BASEURL
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
|
onTalk:Function,
|
||||||
onMountUnmount: Function,
|
onMountUnmount: Function,
|
||||||
discussionPersonalities: Array,
|
discussionPersonalities: Array,
|
||||||
onShowPersList: Function,
|
onShowPersList: Function,
|
||||||
@ -218,6 +221,38 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
},
|
||||||
|
async handleOnTalk(pers){
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
feather.replace()
|
||||||
|
console.log('ppa', pers)
|
||||||
|
if (pers) {
|
||||||
|
|
||||||
|
if (pers.selected) {
|
||||||
|
this.$refs.toast.showToast("Personality already selected", 4, true)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (pers.isMounted) {
|
||||||
|
|
||||||
|
const res = await this.select_personality(pers)
|
||||||
|
if (res) {
|
||||||
|
if (res.status) {
|
||||||
|
await this.constructor()
|
||||||
|
this.$refs.toast.showToast("Selected personality:\n" + pers.name, 4, true)
|
||||||
|
this.onTalk(pers)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
this.onPersonalityMounted(pers)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
async onPersonalitySelected(pers) {
|
async onPersonalitySelected(pers) {
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
@ -79,7 +79,8 @@ props: {
|
|||||||
type: Array,
|
type: Array,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
sendCommand:Function
|
sendCommand:Function,
|
||||||
|
onShowToastMessage:Function
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@ -106,6 +107,7 @@ methods: {
|
|||||||
input.accept = 'application/pdf'; // Specify the file type you want to accept
|
input.accept = 'application/pdf'; // Specify the file type you want to accept
|
||||||
input.onchange = (e) => {
|
input.onchange = (e) => {
|
||||||
this.selectedFile = e.target.files[0];
|
this.selectedFile = e.target.files[0];
|
||||||
|
console.log("File selected")
|
||||||
next()
|
next()
|
||||||
};
|
};
|
||||||
input.click();
|
input.click();
|
||||||
@ -113,11 +115,13 @@ methods: {
|
|||||||
uploadFile() {
|
uploadFile() {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append('file', this.selectedFile);
|
formData.append('file', this.selectedFile);
|
||||||
|
console.log("Uploading file")
|
||||||
|
|
||||||
axios.post('/send_file', formData)
|
axios.post('/send_file', formData)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
// Handle the server response if needed
|
// Handle the server response if needed
|
||||||
console.log(response.data);
|
console.log(response.data);
|
||||||
|
this.onShowToastMessage("File uploaded successfully")
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
// Handle any errors that occur during the upload
|
// Handle any errors that occur during the upload
|
||||||
|
@ -13,12 +13,13 @@
|
|||||||
<h3 class="font-bold font-large text-lg line-clamp-3">
|
<h3 class="font-bold font-large text-lg line-clamp-3">
|
||||||
{{ personality.name }}
|
{{ personality.name }}
|
||||||
</h3>
|
</h3>
|
||||||
<button v-if="selected" type="button" title="Reload personality"
|
<button type="button" title="Talk"
|
||||||
@click="toggleReloadBinding"
|
@click="toggleTalk"
|
||||||
class="hover:text-secondary duration-75 active:scale-90 font-medium rounded-lg text-sm p-2 text-center inline-flex items-center " @click.stop="">
|
class="hover:text-secondary duration-75 active:scale-90 font-medium rounded-lg text-sm p-2 text-center inline-flex items-center " @click.stop="">
|
||||||
<i data-feather="refresh-cw" class="w-5"></i>
|
<i data-feather="send" class="w-5"></i>
|
||||||
<span class="sr-only">Help</span>
|
<span class="sr-only">Talk</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center flex-row-reverse gap-2 my-1">
|
<div class="flex items-center flex-row-reverse gap-2 my-1">
|
||||||
<!-- CONTROLS -->
|
<!-- CONTROLS -->
|
||||||
@ -95,6 +96,7 @@ export default {
|
|||||||
personality: {},
|
personality: {},
|
||||||
selected: Boolean,
|
selected: Boolean,
|
||||||
full_path: String,
|
full_path: String,
|
||||||
|
onTalk:Function,
|
||||||
onSelected: Function,
|
onSelected: Function,
|
||||||
onMounted: Function,
|
onMounted: Function,
|
||||||
onReinstall: Function,
|
onReinstall: Function,
|
||||||
@ -128,6 +130,9 @@ selected_computed(){
|
|||||||
defaultImg(event) {
|
defaultImg(event) {
|
||||||
event.target.src = botImgPlaceholder
|
event.target.src = botImgPlaceholder
|
||||||
},
|
},
|
||||||
|
toggleTalk() {
|
||||||
|
this.onTalk(this)
|
||||||
|
},
|
||||||
toggleSelected() {
|
toggleSelected() {
|
||||||
this.onSelected(this)
|
this.onSelected(this)
|
||||||
},
|
},
|
||||||
|
@ -210,7 +210,14 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class=" bottom-0 container flex flex-row items-center justify-center " v-if="currentDiscussion.id">
|
<div class=" bottom-0 container flex flex-row items-center justify-center " v-if="currentDiscussion.id">
|
||||||
<ChatBox ref="chatBox" @messageSentEvent="sendMsg" :loading="isGenerating" :discussionList="discussionArr" @stopGenerating="stopGenerating">
|
<ChatBox ref="chatBox"
|
||||||
|
@messageSentEvent="sendMsg"
|
||||||
|
:loading="isGenerating"
|
||||||
|
:discussionList="discussionArr"
|
||||||
|
@stopGenerating="stopGenerating"
|
||||||
|
:on-show-toast-message="showToastMessage"
|
||||||
|
:on-talk="talk"
|
||||||
|
>
|
||||||
</ChatBox>
|
</ChatBox>
|
||||||
</div>
|
</div>
|
||||||
<!-- CAN ADD FOOTER PANEL HERE -->
|
<!-- CAN ADD FOOTER PANEL HERE -->
|
||||||
@ -349,6 +356,10 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
showToastMessage(text){
|
||||||
|
console.log("sending",text)
|
||||||
|
this.$refs.toast.showToast(text, 4, true)
|
||||||
|
},
|
||||||
togglePanel() {
|
togglePanel() {
|
||||||
this.panelCollapsed = !this.panelCollapsed;
|
this.panelCollapsed = !this.panelCollapsed;
|
||||||
},
|
},
|
||||||
@ -780,6 +791,29 @@ export default {
|
|||||||
this.chime.play()
|
this.chime.play()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
talk(pers){
|
||||||
|
this.isGenerating = true;
|
||||||
|
this.setDiscussionLoading(this.currentDiscussion.id, this.isGenerating);
|
||||||
|
axios.get('/get_generation_status', {}).then((res) => {
|
||||||
|
if (res) {
|
||||||
|
//console.log(res.data.status);
|
||||||
|
if (!res.data.status) {
|
||||||
|
socket.emit('generate_msg_from', { id: -1 });
|
||||||
|
// Temp data
|
||||||
|
let lastmsgid =0
|
||||||
|
if(this.discussionArr.length>0){
|
||||||
|
lastmsgid= Number(this.discussionArr[this.discussionArr.length - 1].id) + 1
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.log("Already generating");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).catch((error) => {
|
||||||
|
console.log("Error: Could not get generation status", error);
|
||||||
|
});
|
||||||
|
},
|
||||||
sendMsg(msg) {
|
sendMsg(msg) {
|
||||||
// Sends message to binding
|
// Sends message to binding
|
||||||
if (!msg) {
|
if (!msg) {
|
||||||
@ -838,13 +872,14 @@ export default {
|
|||||||
messageItem.steps.push({"message":msgObj.data,"done":false})
|
messageItem.steps.push({"message":msgObj.data,"done":false})
|
||||||
|
|
||||||
} else if (msgObj.message_type == this.msgTypes.MSG_TYPE_STEP_END) {
|
} else if (msgObj.message_type == this.msgTypes.MSG_TYPE_STEP_END) {
|
||||||
|
|
||||||
// Find the step with the matching message and update its 'done' property to true
|
// Find the step with the matching message and update its 'done' property to true
|
||||||
const matchingStep = messageItem.steps.find(step => step.message === msgObj.data);
|
const matchingStep = messageItem.steps.find(step => step.message === msgObj.data);
|
||||||
|
|
||||||
if (matchingStep) {
|
if (matchingStep) {
|
||||||
matchingStep.done = true;
|
matchingStep.done = true;
|
||||||
}
|
}
|
||||||
|
} else if (msgObj.message_type == this.msgTypes.MSG_TYPE_EXCEPTION) {
|
||||||
|
this.$refs.toast.showToast(msgObj.data, 4, true)
|
||||||
}
|
}
|
||||||
// // Disables as per request
|
// // Disables as per request
|
||||||
// nextTick(() => {
|
// nextTick(() => {
|
||||||
@ -1066,8 +1101,6 @@ export default {
|
|||||||
console.log(res);
|
console.log(res);
|
||||||
if (!res.data.status) {
|
if (!res.data.status) {
|
||||||
socket.emit('generate_msg_from', { prompt: msg, id: msgId });
|
socket.emit('generate_msg_from', { prompt: msg, id: msgId });
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
console.log("Already generating");
|
console.log("Already generating");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user