Commit 270c16c0 authored by 박민석's avatar 박민석

log check -- msg chunk

parent b0b53cdb
Pipeline #21183 passed with stages
in 4 minutes and 20 seconds
...@@ -192,20 +192,21 @@ ...@@ -192,20 +192,21 @@
body: JSON.stringify(payload), body: JSON.stringify(payload),
}) })
.then((response) => { .then((response) => {
const reader = response.body?.getReader() const reader = response.body.getReader()
const decoder = new TextDecoder('utf-8') const decoder = new TextDecoder('utf-8')
const messageItem = document.createElement('pre') const messageItem = document.createElement('pre')
messageItem.className = 'message ai' messageItem.className = 'message ai'
function readStream () { function readStream () {
return reader?.read().then(({ done, value }) => { return reader.read().then(({ done, value }) => {
if (done) { if (done) {
chatBody.removeChild(chatLoader) chatBody.removeChild(chatLoader)
isLoading = false isLoading = false
return return
} }
const chunk = decoder.decode(value, { stream: true }) const chunk = decoder.decode(value, { stream: true })
console.log(chunk)
messageItem.textContent += chunk messageItem.textContent += chunk
chatBody.scrollTop = chatBody?.scrollHeight chatBody.scrollTop = chatBody?.scrollHeight
return readStream() return readStream()
......
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