Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
SWLab UI
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Jobs
Commits
Open sidebar
SWD
SWLab UI
Commits
270c16c0
Commit
270c16c0
authored
5 months ago
by
박민석
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
log check -- msg chunk
parent
b0b53cdb
Pipeline
#21183
passed with stages
in 4 minutes and 20 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
2 deletions
+3
-2
08-chat.js
src/js/08-chat.js
+3
-2
No files found.
src/js/08-chat.js
View file @
270c16c0
...
@@ -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
()
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment