Spaces:
Configuration error
Configuration error
Download frontend/src/components/features/chat/messages.tsx from flyingdarkdev/README: direct link, hf CLI and curl.
- Browser
- Download file 1.6 kB
-
https://huggingface.co/spaces/flyingdarkdev/README/resolve/main/frontend/src/components/features/chat/messages.tsx
- Command line
-
hf download hf://spaces/flyingdarkdev/README/frontend/src/components/features/chat/messages.tsx
-
curl -L -o messages.tsx https://huggingface.co/spaces/flyingdarkdev/README/resolve/main/frontend/src/components/features/chat/messages.tsx
1.6 kB
| import React from "react"; | |
| import type { Message } from "#/message"; | |
| import { ChatMessage } from "#/components/features/chat/chat-message"; | |
| import { ConfirmationButtons } from "#/components/shared/buttons/confirmation-buttons"; | |
| import { ImageCarousel } from "../images/image-carousel"; | |
| import { ExpandableMessage } from "./expandable-message"; | |
| interface MessagesProps { | |
| messages: Message[]; | |
| isAwaitingUserConfirmation: boolean; | |
| } | |
| export const Messages: React.FC<MessagesProps> = React.memo( | |
| ({ messages, isAwaitingUserConfirmation }) => | |
| messages.map((message, index) => { | |
| const shouldShowConfirmationButtons = | |
| messages.length - 1 === index && | |
| message.sender === "assistant" && | |
| isAwaitingUserConfirmation; | |
| if (message.type === "error" || message.type === "action") { | |
| return ( | |
| <div key={index}> | |
| <ExpandableMessage | |
| type={message.type} | |
| id={message.translationID} | |
| message={message.content} | |
| success={message.success} | |
| /> | |
| {shouldShowConfirmationButtons && <ConfirmationButtons />} | |
| </div> | |
| ); | |
| } | |
| return ( | |
| <ChatMessage | |
| key={index} | |
| type={message.sender} | |
| message={message.content} | |
| > | |
| {message.imageUrls && message.imageUrls.length > 0 && ( | |
| <ImageCarousel size="small" images={message.imageUrls} /> | |
| )} | |
| {shouldShowConfirmationButtons && <ConfirmationButtons />} | |
| </ChatMessage> | |
| ); | |
| }), | |
| ); | |
| Messages.displayName = "Messages"; | |