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
04a98081
Commit
04a98081
authored
Sep 20, 2024
by
박민석
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add chatLoader
parent
618456f2
Pipeline
#21107
passed with stages
in 3 minutes and 46 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
28 deletions
+20
-28
08-chat.js
src/js/08-chat.js
+20
-28
No files found.
src/js/08-chat.js
View file @
04a98081
...
...
@@ -164,21 +164,25 @@
chatBody
.
appendChild
(
user
)
chatBody
.
scrollTop
=
chatBody
.
scrollHeight
if
(
!
docType
)
{
createAiMessage
(
'가이드 도움에 필요한 제품을 선택해주세요.'
)
return
}
//
if (!docType) {
//
createAiMessage('가이드 도움에 필요한 제품을 선택해주세요.')
//
return
//
}
isLoading
=
true
const
messageItem
=
document
.
createElement
(
'pre'
)
messageItem
.
className
=
'message ai'
chatBody
.
appendChild
(
messageItem
)
const
chatLoader
=
document
.
createElement
(
'div'
)
chatLoader
.
className
=
'chat-loader'
const
loader
=
document
.
createElement
(
'div'
)
loader
.
className
=
'loader'
chatLoader
.
appendChild
(
loader
)
chatBody
.
appendChild
(
chatLoader
)
chatBody
.
scrollTop
=
chatBody
.
scrollHeight
const
payload
=
{
question
:
message
,
docsType
:
docType
.
toLowerCase
(),
// docsType: docType.toLowerCase(),
docsType
:
'bxi'
,
}
fetch
(
'https://docs.bxi.link/ask'
,
{
...
...
@@ -192,9 +196,13 @@
const
reader
=
response
.
body
?.
getReader
()
const
decoder
=
new
TextDecoder
(
'utf-8'
)
const
messageItem
=
document
.
createElement
(
'pre'
)
messageItem
.
className
=
'message ai'
function
readStream
()
{
return
reader
?.
read
().
then
(({
done
,
value
})
=>
{
if
(
done
)
{
chatBody
.
removeChild
(
chatLoader
)
isLoading
=
false
return
}
...
...
@@ -205,32 +213,16 @@
})
}
chatBody
.
appendChild
(
messageItem
)
chatBody
.
scrollTop
=
chatBody
.
scrollHeight
return
readStream
()
})
.
catch
((
error
)
=>
{
console
.
error
(
'Chatbot Error'
,
error
)
chatBody
.
removeChild
(
chatLoader
)
isLoading
=
false
})
// const chatLoader = document.createElement('div')
// chatLoader.className = 'chat-loader'
// const loader = document.createElement('div')
// loader.className = 'loader'
// chatLoader.appendChild(loader)
// chatBody.appendChild(chatLoader)
// chatBody.scrollTop = chatBody.scrollHeight
// setTimeout(() => {
// chatBody.removeChild(chatLoader)
// const ai = document.createElement('pre')
// ai.className = 'message ai'
// ai.textContent = '지금은 답해드릴 수 없어요.'
// chatBody.appendChild(ai)
// chatBody.scrollTop = chatBody.scrollHeight
// isLoading = false
// }, 3000)
}
}
...
...
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