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()
|
print()
|
||||||
|
|
||||||
# Send final message
|
# 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.current_discussion.update_message(response_id, self.bot_says)
|
||||||
self.full_message_list.append(self.bot_says)
|
self.full_message_list.append(self.bot_says)
|
||||||
|
@ -180,7 +180,7 @@ class GPT4AllAPI():
|
|||||||
|
|
||||||
self.bot_says += text
|
self.bot_says += text
|
||||||
if not self.personality.detect_antiprompt(self.bot_says):
|
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:
|
if self.cancel_gen:
|
||||||
print("Generation canceled")
|
print("Generation canceled")
|
||||||
self.cancel_gen = False
|
self.cancel_gen = False
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
@click.stop="copyContentToClipboard()">
|
@click.stop="copyContentToClipboard()">
|
||||||
<i data-feather="copy"></i>
|
<i data-feather="copy"></i>
|
||||||
</div>
|
</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>
|
<i data-feather="refresh-cw"></i>
|
||||||
</div>
|
</div>
|
||||||
<!-- DELETE CONFIRMATION -->
|
<!-- DELETE CONFIRMATION -->
|
||||||
@ -83,7 +83,7 @@ import feather from 'feather-icons'
|
|||||||
import MarkdownRenderer from './MarkdownRenderer.vue';
|
import MarkdownRenderer from './MarkdownRenderer.vue';
|
||||||
export default {
|
export default {
|
||||||
name: 'Message',
|
name: 'Message',
|
||||||
emits: ['copy', 'delete', 'rankUp', 'rankDown','updateMessage'],
|
emits: ['copy', 'delete', 'rankUp', 'rankDown','updateMessage','resendMessage'],
|
||||||
components: {
|
components: {
|
||||||
MarkdownRenderer
|
MarkdownRenderer
|
||||||
},
|
},
|
||||||
@ -128,6 +128,9 @@ export default {
|
|||||||
this.$emit('updateMessage', this.message.id, this.new_message_content)
|
this.$emit('updateMessage', this.message.id, this.new_message_content)
|
||||||
this.editMsgMode = false
|
this.editMsgMode = false
|
||||||
},
|
},
|
||||||
|
resendMessage(){
|
||||||
|
this.$emit('resendMessage', this.message.id, this.new_message_content)
|
||||||
|
},
|
||||||
getImgUrl() {
|
getImgUrl() {
|
||||||
|
|
||||||
if (this.message.sender == "user") {
|
if (this.message.sender == "user") {
|
||||||
|
@ -109,10 +109,10 @@
|
|||||||
|
|
||||||
<!-- CHAT AREA -->
|
<!-- CHAT AREA -->
|
||||||
<div class="flex flex-col flex-grow">
|
<div class="flex flex-col flex-grow">
|
||||||
<!-- REMOVED @click="scrollToElement($event.target)" -->
|
<!-- REMOVED @click="scrollToElement($event.target)" -->
|
||||||
<Message v-for="(msg, index) in discussionArr" :key="index" :message="msg"
|
<Message v-for="(msg, index) in discussionArr" :key="index" :message="msg" :id="'msg-' + msg.id" ref="messages"
|
||||||
:id="'msg-' + msg.id" ref="messages" @copy="copyToClipBoard"
|
@copy="copyToClipBoard" @delete="deleteMessage" @rankUp="rankUpMessage" @rankDown="rankDownMessage"
|
||||||
@delete="deleteMessage" @rankUp="rankUpMessage" @rankDown="rankDownMessage" @updateMessage="updateMessage"/>
|
@updateMessage="updateMessage" @resendMessage="resendMessage" />
|
||||||
|
|
||||||
<WelcomeComponent v-if="!currentDiscussion.id" />
|
<WelcomeComponent v-if="!currentDiscussion.id" />
|
||||||
|
|
||||||
@ -308,7 +308,7 @@ export default {
|
|||||||
},
|
},
|
||||||
async update_message(id, message) {
|
async update_message(id, message) {
|
||||||
try {
|
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) {
|
if (res) {
|
||||||
return res.data
|
return res.data
|
||||||
@ -409,7 +409,7 @@ export default {
|
|||||||
let responseMessage = {
|
let responseMessage = {
|
||||||
content: '..typing',
|
content: '..typing',
|
||||||
id: msgObj.response_id,
|
id: msgObj.response_id,
|
||||||
//parent: 10,
|
parent: msgObj.id,
|
||||||
rank: 0,
|
rank: 0,
|
||||||
sender: msgObj.bot
|
sender: msgObj.bot
|
||||||
//type: 0
|
//type: 0
|
||||||
@ -425,7 +425,7 @@ export default {
|
|||||||
if (this.currentDiscussion.title === '' || this.currentDiscussion.title === null) {
|
if (this.currentDiscussion.title === '' || this.currentDiscussion.title === null) {
|
||||||
this.changeTitleUsingUserMSG(this.currentDiscussion.id, msgObj.content)
|
this.changeTitleUsingUserMSG(this.currentDiscussion.id, msgObj.content)
|
||||||
}
|
}
|
||||||
|
console.log("infos",msgObj)
|
||||||
},
|
},
|
||||||
sendMsg(msg) {
|
sendMsg(msg) {
|
||||||
// Sends message to backend
|
// Sends message to backend
|
||||||
@ -458,9 +458,22 @@ export default {
|
|||||||
},
|
},
|
||||||
steamMessageContent(content) {
|
steamMessageContent(content) {
|
||||||
// Streams response message content from backend
|
// Streams response message content from backend
|
||||||
//console.log(content)
|
//console.log("stream", JSON.stringify(content))
|
||||||
const lastMsg = this.discussionArr[this.discussionArr.length - 1]
|
const parent = content.parent
|
||||||
lastMsg.content = content.data
|
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) {
|
async changeTitleUsingUserMSG(id, msg) {
|
||||||
// If discussion is untitled or title is null then it sets the title to first user message.
|
// If discussion is untitled or title is null then it sets the title to first user message.
|
||||||
@ -622,9 +635,9 @@ export default {
|
|||||||
},
|
},
|
||||||
async rankUpMessage(msgId) {
|
async rankUpMessage(msgId) {
|
||||||
await this.message_rank_up(msgId).then((res) => {
|
await this.message_rank_up(msgId).then((res) => {
|
||||||
|
|
||||||
const message = this.discussionArr[this.discussionArr.findIndex(item => item.id == msgId)]
|
const message = this.discussionArr[this.discussionArr.findIndex(item => item.id == msgId)]
|
||||||
message.rank= res.new_rank
|
message.rank = res.new_rank
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
|
|
||||||
console.log("Error: Could not rank up message")
|
console.log("Error: Could not rank up message")
|
||||||
@ -633,9 +646,9 @@ export default {
|
|||||||
},
|
},
|
||||||
async rankDownMessage(msgId) {
|
async rankDownMessage(msgId) {
|
||||||
await this.message_rank_down(msgId).then((res) => {
|
await this.message_rank_down(msgId).then((res) => {
|
||||||
|
|
||||||
const message = this.discussionArr[this.discussionArr.findIndex(item => item.id == msgId)]
|
const message = this.discussionArr[this.discussionArr.findIndex(item => item.id == msgId)]
|
||||||
message.rank= res.new_rank
|
message.rank = res.new_rank
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
|
|
||||||
console.log("Error: Could not rank down message")
|
console.log("Error: Could not rank down message")
|
||||||
@ -644,16 +657,36 @@ export default {
|
|||||||
},
|
},
|
||||||
async updateMessage(msgId, msg) {
|
async updateMessage(msgId, msg) {
|
||||||
await this.update_message(msgId, msg).then(() => {
|
await this.update_message(msgId, msg).then(() => {
|
||||||
|
|
||||||
const message = this.discussionArr[this.discussionArr.findIndex(item => item.id == msgId)]
|
const message = this.discussionArr[this.discussionArr.findIndex(item => item.id == msgId)]
|
||||||
message.content= msg
|
message.content = msg
|
||||||
|
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
|
|
||||||
console.log("Error: Could not update message")
|
console.log("Error: Could not update message")
|
||||||
})
|
})
|
||||||
|
|
||||||
},
|
},
|
||||||
|
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() {
|
stopGenerating() {
|
||||||
this.stop_gen()
|
this.stop_gen()
|
||||||
this.isGenerating = false
|
this.isGenerating = false
|
||||||
@ -696,6 +729,7 @@ export default {
|
|||||||
socket.on('infos', this.createBotMsg)
|
socket.on('infos', this.createBotMsg)
|
||||||
socket.on('message', this.steamMessageContent)
|
socket.on('message', this.steamMessageContent)
|
||||||
socket.on("final", this.finalMsgEvent)
|
socket.on("final", this.finalMsgEvent)
|
||||||
|
|
||||||
},
|
},
|
||||||
activated() {
|
activated() {
|
||||||
// This lifecycle hook runs every time you switch from other page back to this page (vue-router)
|
// 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