Commit 7866693e authored by 박민석's avatar 박민석

test chatbot

parent da41f056
Pipeline #21073 failed with stages
in 1 minute and 35 seconds
...@@ -171,6 +171,11 @@ ...@@ -171,6 +171,11 @@
isLoading = true isLoading = true
const messageItem = document.createElement('pre')
messageItem.className = 'message ai'
chatBody.appendChild(messageItem)
chatBody.scrollTop = chatBody.scrollHeight
const payload = { const payload = {
question: message, question: message,
docsType: docType.toLowerCase(), docsType: docType.toLowerCase(),
...@@ -184,10 +189,27 @@ ...@@ -184,10 +189,27 @@
body: JSON.stringify(payload), body: JSON.stringify(payload),
}) })
.then((response) => { .then((response) => {
console.log(response) // response 확인 테스트 const reader = response.body?.getReader()
const decoder = new TextDecoder('utf-8')
function readStream() {
return reader?.read().then(({ done, value }) => {
if (done) {
isLoading = false
return
}
const chunk = decoder.decode(value, { stream: true })
messageItem.textContent += chunk
chatBody.scrollTop = chatBody?.scrollHeight
return readStream()
})
}
return readStream()
}) })
.catch((error) => { .catch((error) => {
console.error('Chatbot Error', error) console.error('Chatbot Error', error)
isLoading = false
}) })
// const chatLoader = document.createElement('div') // const chatLoader = document.createElement('div')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment