Merge pull request #165 from andzejsp/main

Latest build, improved chat
This commit is contained in:
Saifeddine ALOUI 2023-05-09 14:28:30 +02:00 committed by GitHub
commit c6a32a9e44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 43 additions and 25 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

4
web/dist/index.html vendored
View File

@ -6,8 +6,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GPT4All - WEBUI</title> <title>GPT4All - WEBUI</title>
<script type="module" crossorigin src="/assets/index-d538588b.js"></script> <script type="module" crossorigin src="/assets/index-0997c0cd.js"></script>
<link rel="stylesheet" href="/assets/index-76bec145.css"> <link rel="stylesheet" href="/assets/index-c63da122.css">
</head> </head>
<body> <body>
<div id="app"></div> <div id="app"></div>

View File

@ -348,8 +348,11 @@ export default {
} }
} }
nextTick(() => { nextTick(() => {
const selectedDisElement = document.getElementById('dis-' + item.id) // const selectedDisElement = document.getElementById('dis-' + item.id)
this.scrollToElement(selectedDisElement) // this.scrollToElement(selectedDisElement)
const msgList = document.getElementById('messages-list')
this.scrollBottom(msgList)
}) })
} }
}, },
@ -396,7 +399,7 @@ export default {
const lastMsg = this.discussionArr[this.discussionArr.length - 1] const lastMsg = this.discussionArr[this.discussionArr.length - 1]
lastMsg.content = msgObj.message lastMsg.content = msgObj.message
lastMsg.id = msgObj.id lastMsg.id = msgObj.user_message_id
// lastMsg.parent=msgObj.parent // lastMsg.parent=msgObj.parent
lastMsg.rank = msgObj.rank lastMsg.rank = msgObj.rank
lastMsg.sender = msgObj.user lastMsg.sender = msgObj.user
@ -404,15 +407,25 @@ export default {
}, },
createBotMsg(msgObj) { createBotMsg(msgObj) {
// Update previous message with reponse user data // Update previous message with reponse user data
//
// msgObj
//
// "type": "input_message_infos",
// "bot": self.personality.name,
// "user": self.personality.user_name,
// "message":message,#markdown.markdown(message),
// "user_message_id": self.current_user_message_id,
// "ai_message_id": self.current_ai_message_id,
this.updateLastUserMsg(msgObj) this.updateLastUserMsg(msgObj)
// Create response message // Create response message
let responseMessage = { let responseMessage = {
content: '..typing', content: "..typing",//msgObj.message,
id: msgObj.ai_message_id, id: msgObj.ai_message_id,
parent: msgObj.id, parent: msgObj.user_message_id,
rank: 0, rank: 0,
sender: msgObj.bot sender: msgObj.bot,
//type: 0 //type: msgObj.type
} }
this.discussionArr.push(responseMessage) this.discussionArr.push(responseMessage)
nextTick(() => { nextTick(() => {
@ -423,7 +436,11 @@ 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) if (msgObj.type == "input_message_infos") {
// This is a user input
this.changeTitleUsingUserMSG(this.currentDiscussion.id, msgObj.message)
}
} }
console.log("infos", msgObj) console.log("infos", msgObj)
}, },
@ -456,18 +473,19 @@ export default {
console.log("Error: Could not get generation status", error); console.log("Error: Could not get generation status", error);
}); });
}, },
steamMessageContent(content) { steamMessageContent(msgObj) {
// Streams response message content from backend // Streams response message content from backend
//console.log("stream", JSON.stringify(content)) //console.log("stream", JSON.stringify(content))
const parent = content.parent const parent = msgObj.user_message_id
const discussion_id = content.discussion_id const discussion_id = msgObj.discussion_id
if (this.currentDiscussion.id = discussion_id) { if (this.currentDiscussion.id = discussion_id) {
const index = this.discussionArr.findIndex((x) => x.parent == parent) const index = this.discussionArr.findIndex((x) => x.parent == parent && x.id == msgObj.ai_message_id)
const messageItem = this.discussionArr[index] const messageItem = this.discussionArr[index]
if (messageItem) { if (messageItem) {
messageItem.content = content.data messageItem.content = msgObj.data
//console.log(parent, index, discussion_id, content.data) //console.log("user-msg-id",parent, "ai-msg-id",msgObj.ai_message_id, index, discussion_id, msgObj.data)
} }
} }
@ -691,17 +709,17 @@ export default {
this.isGenerating = false this.isGenerating = false
console.log("Stopped generating") console.log("Stopped generating")
}, },
finalMsgEvent(data) { finalMsgEvent(msgObj) {
console.log("final", data) console.log("final", msgObj)
// Last message contains halucination suppression so we need to update the message content too // Last message contains halucination suppression so we need to update the message content too
const parent = content.parent const parent = msgObj.parent
const discussion_id = content.discussion_id const discussion_id = msgObj.discussion_id
if (this.currentDiscussion.id = discussion_id) { if (this.currentDiscussion.id = discussion_id) {
const index = this.discussionArr.findIndex((x) => x.parent == parent) const index = this.discussionArr.findIndex((x) => x.parent == parent && x.id == msgObj.ai_message_id)
const messageItem = this.discussionArr[index] const messageItem = this.discussionArr[index]
if (messageItem) { if (messageItem) {
messageItem.content = content.data messageItem.content = msgObj.data
} }
} }