mirror of
https://github.com/ParisNeo/lollms-webui.git
synced 2025-01-19 11:16:25 +00:00
commit
e8acc45c90
3
app.py
3
app.py
@ -495,7 +495,8 @@ class Gpt4AllWebUI(GPT4AllAPI):
|
||||
print()
|
||||
|
||||
# Send final message
|
||||
self.socketio.emit('final', {'data': self.bot_says})
|
||||
self.socketio.emit('final', {'data': self.bot_says, 'response_id':response_id, 'parent':self.current_message_id, 'discussion_id':self.current_discussion.discussion_id})
|
||||
|
||||
|
||||
self.current_discussion.update_message(response_id, self.bot_says)
|
||||
self.full_message_list.append(self.bot_says)
|
||||
|
@ -180,7 +180,7 @@ class GPT4AllAPI():
|
||||
|
||||
self.bot_says += text
|
||||
if not self.personality.detect_antiprompt(self.bot_says):
|
||||
self.socketio.emit('message', {'data': self.bot_says})
|
||||
self.socketio.emit('message', {'data': self.bot_says, 'parent':self.current_message_id, 'discussion_id':self.current_discussion.discussion_id})
|
||||
if self.cancel_gen:
|
||||
print("Generation canceled")
|
||||
self.cancel_gen = False
|
||||
|
@ -40,7 +40,7 @@
|
||||
@click.stop="copyContentToClipboard()">
|
||||
<i data-feather="copy"></i>
|
||||
</div>
|
||||
<div class="text-lg hover:text-secondary duration-75 active:scale-90 p-2" title="Resend message">
|
||||
<div class="text-lg hover:text-secondary duration-75 active:scale-90 p-2" title="Resend message" @click.stop="resendMessage()">
|
||||
<i data-feather="refresh-cw"></i>
|
||||
</div>
|
||||
<!-- DELETE CONFIRMATION -->
|
||||
@ -83,7 +83,7 @@ import feather from 'feather-icons'
|
||||
import MarkdownRenderer from './MarkdownRenderer.vue';
|
||||
export default {
|
||||
name: 'Message',
|
||||
emits: ['copy', 'delete', 'rankUp', 'rankDown','updateMessage'],
|
||||
emits: ['copy', 'delete', 'rankUp', 'rankDown','updateMessage','resendMessage'],
|
||||
components: {
|
||||
MarkdownRenderer
|
||||
},
|
||||
@ -128,6 +128,9 @@ export default {
|
||||
this.$emit('updateMessage', this.message.id, this.new_message_content)
|
||||
this.editMsgMode = false
|
||||
},
|
||||
resendMessage(){
|
||||
this.$emit('resendMessage', this.message.id, this.new_message_content)
|
||||
},
|
||||
getImgUrl() {
|
||||
|
||||
if (this.message.sender == "user") {
|
||||
|
@ -110,9 +110,9 @@
|
||||
<!-- CHAT AREA -->
|
||||
<div class="flex flex-col flex-grow">
|
||||
<!-- REMOVED @click="scrollToElement($event.target)" -->
|
||||
<Message v-for="(msg, index) in discussionArr" :key="index" :message="msg"
|
||||
:id="'msg-' + msg.id" ref="messages" @copy="copyToClipBoard"
|
||||
@delete="deleteMessage" @rankUp="rankUpMessage" @rankDown="rankDownMessage" @updateMessage="updateMessage"/>
|
||||
<Message v-for="(msg, index) in discussionArr" :key="index" :message="msg" :id="'msg-' + msg.id" ref="messages"
|
||||
@copy="copyToClipBoard" @delete="deleteMessage" @rankUp="rankUpMessage" @rankDown="rankDownMessage"
|
||||
@updateMessage="updateMessage" @resendMessage="resendMessage" />
|
||||
|
||||
<WelcomeComponent v-if="!currentDiscussion.id" />
|
||||
|
||||
@ -308,7 +308,7 @@ export default {
|
||||
},
|
||||
async update_message(id, message) {
|
||||
try {
|
||||
const res = await axios.get('/update_message', { params: { id: id, message:message } })
|
||||
const res = await axios.get('/update_message', { params: { id: id, message: message } })
|
||||
|
||||
if (res) {
|
||||
return res.data
|
||||
@ -409,7 +409,7 @@ export default {
|
||||
let responseMessage = {
|
||||
content: '..typing',
|
||||
id: msgObj.response_id,
|
||||
//parent: 10,
|
||||
parent: msgObj.id,
|
||||
rank: 0,
|
||||
sender: msgObj.bot
|
||||
//type: 0
|
||||
@ -425,7 +425,7 @@ export default {
|
||||
if (this.currentDiscussion.title === '' || this.currentDiscussion.title === null) {
|
||||
this.changeTitleUsingUserMSG(this.currentDiscussion.id, msgObj.content)
|
||||
}
|
||||
|
||||
console.log("infos",msgObj)
|
||||
},
|
||||
sendMsg(msg) {
|
||||
// Sends message to backend
|
||||
@ -458,9 +458,22 @@ export default {
|
||||
},
|
||||
steamMessageContent(content) {
|
||||
// Streams response message content from backend
|
||||
//console.log(content)
|
||||
const lastMsg = this.discussionArr[this.discussionArr.length - 1]
|
||||
lastMsg.content = content.data
|
||||
//console.log("stream", JSON.stringify(content))
|
||||
const parent = content.parent
|
||||
const discussion_id = content.discussion_id
|
||||
if (this.currentDiscussion.id = discussion_id) {
|
||||
const index = this.discussionArr.findIndex((x) => x.parent == parent)
|
||||
const messageItem = this.discussionArr[index]
|
||||
if (messageItem) {
|
||||
messageItem.content = content.data
|
||||
//console.log(parent, index, discussion_id, content.data)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//const lastMsg = this.discussionArr[this.discussionArr.length - 1]
|
||||
//lastMsg.content = content.data
|
||||
},
|
||||
async changeTitleUsingUserMSG(id, msg) {
|
||||
// If discussion is untitled or title is null then it sets the title to first user message.
|
||||
@ -624,7 +637,7 @@ export default {
|
||||
await this.message_rank_up(msgId).then((res) => {
|
||||
|
||||
const message = this.discussionArr[this.discussionArr.findIndex(item => item.id == msgId)]
|
||||
message.rank= res.new_rank
|
||||
message.rank = res.new_rank
|
||||
}).catch(() => {
|
||||
|
||||
console.log("Error: Could not rank up message")
|
||||
@ -635,7 +648,7 @@ export default {
|
||||
await this.message_rank_down(msgId).then((res) => {
|
||||
|
||||
const message = this.discussionArr[this.discussionArr.findIndex(item => item.id == msgId)]
|
||||
message.rank= res.new_rank
|
||||
message.rank = res.new_rank
|
||||
}).catch(() => {
|
||||
|
||||
console.log("Error: Could not rank down message")
|
||||
@ -646,7 +659,7 @@ export default {
|
||||
await this.update_message(msgId, msg).then(() => {
|
||||
|
||||
const message = this.discussionArr[this.discussionArr.findIndex(item => item.id == msgId)]
|
||||
message.content= msg
|
||||
message.content = msg
|
||||
|
||||
}).catch(() => {
|
||||
|
||||
@ -654,6 +667,26 @@ export default {
|
||||
})
|
||||
|
||||
},
|
||||
resendMessage(msgId, msg) {
|
||||
// Resend message
|
||||
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', { prompt: msg, id: msgId });
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
console.log("Already generating");
|
||||
}
|
||||
}
|
||||
}).catch((error) => {
|
||||
console.log("Error: Could not get generation status", error);
|
||||
});
|
||||
},
|
||||
stopGenerating() {
|
||||
this.stop_gen()
|
||||
this.isGenerating = false
|
||||
@ -696,6 +729,7 @@ export default {
|
||||
socket.on('infos', this.createBotMsg)
|
||||
socket.on('message', this.steamMessageContent)
|
||||
socket.on("final", this.finalMsgEvent)
|
||||
|
||||
},
|
||||
activated() {
|
||||
// This lifecycle hook runs every time you switch from other page back to this page (vue-router)
|
||||
|
Loading…
Reference in New Issue
Block a user