Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Create Llama
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
MachineLearning
run-llama
Create Llama
Commits
2ba92998
Commit
2ba92998
authored
1 year ago
by
Alex Yang
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
feat: add loading indicator (#203)
parent
ff72dea4
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
templates/components/ui/shadcn/chat/chat-messages.tsx
+13
-0
13 additions, 0 deletions
templates/components/ui/shadcn/chat/chat-messages.tsx
templates/types/streaming/nextjs/package.json
+1
-1
1 addition, 1 deletion
templates/types/streaming/nextjs/package.json
with
14 additions
and
1 deletion
templates/components/ui/shadcn/chat/chat-messages.tsx
+
13
−
0
View file @
2ba92998
import
{
useEffect
,
useRef
}
from
"
react
"
;
import
{
useEffect
,
useRef
}
from
"
react
"
;
import
{
Loader2
}
from
"
lucide-react
"
;
import
ChatActions
from
"
./chat-actions
"
;
import
ChatActions
from
"
./chat-actions
"
;
import
ChatMessage
from
"
./chat-message
"
;
import
ChatMessage
from
"
./chat-message
"
;
...
@@ -24,6 +25,11 @@ export default function ChatMessages(
...
@@ -24,6 +25,11 @@ export default function ChatMessages(
props
.
reload
&&
!
props
.
isLoading
&&
isLastMessageFromAssistant
;
props
.
reload
&&
!
props
.
isLoading
&&
isLastMessageFromAssistant
;
const
showStop
=
props
.
stop
&&
props
.
isLoading
;
const
showStop
=
props
.
stop
&&
props
.
isLoading
;
// `isPending` indicate
// that stream response is not yet received from the server,
// so we show a loading indicator to give a better UX.
const
isPending
=
props
.
isLoading
&&
!
isLastMessageFromAssistant
;
useEffect
(()
=>
{
useEffect
(()
=>
{
scrollToBottom
();
scrollToBottom
();
},
[
messageLength
,
lastMessage
]);
},
[
messageLength
,
lastMessage
]);
...
@@ -37,6 +43,13 @@ export default function ChatMessages(
...
@@ -37,6 +43,13 @@ export default function ChatMessages(
{
props
.
messages
.
map
((
m
)
=>
(
{
props
.
messages
.
map
((
m
)
=>
(
<
ChatMessage
key
=
{
m
.
id
}
{
...
m
}
/>
<
ChatMessage
key
=
{
m
.
id
}
{
...
m
}
/>
))
}
))
}
{
isPending
&&
(
<
div
className
=
'flex justify-center items-center pt-10'
>
<
Loader2
className
=
"h-4 w-4 animate-spin"
/>
</
div
>
)
}
</
div
>
</
div
>
<
div
className
=
"flex justify-end py-4"
>
<
div
className
=
"flex justify-end py-4"
>
<
ChatActions
<
ChatActions
...
...
This diff is collapsed.
Click to expand it.
templates/types/streaming/nextjs/package.json
+
1
−
1
View file @
2ba92998
...
@@ -26,4 +26,4 @@
...
@@ -26,4 +26,4 @@
"tailwindcss"
:
"^3.3"
,
"tailwindcss"
:
"^3.3"
,
"typescript"
:
"^5"
"typescript"
:
"^5"
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment