buster/web/src/controllers/ReasoningController/ReasoningMessages/ReasoningMessage_Files/ReasoningMessage_Files.tsx

61 lines
1.9 KiB
TypeScript
Raw Normal View History

2025-03-05 00:32:47 +08:00
import React from 'react';
import type { ReasoningMessageProps } from '../ReasoningMessageSelector';
import type { BusterChatMessageReasoning_files } from '@/api/asset_interfaces/chat';
import { BarContainer } from '../BarContainer';
import { ReasoningMessage_File } from './ReasoningMessageFile';
2025-03-06 04:14:24 +08:00
import { useMessageIndividual } from '@/context/Chats';
2025-03-05 00:32:47 +08:00
export const ReasoningMessage_Files: React.FC<ReasoningMessageProps> = React.memo(
2025-03-06 04:14:24 +08:00
({ isCompletedStream, chatId, reasoningMessageId, messageId }) => {
2025-03-06 06:49:46 +08:00
const status = useMessageIndividual(
2025-03-06 04:14:24 +08:00
messageId,
2025-03-06 06:49:46 +08:00
(x) => (x?.reasoning_messages[reasoningMessageId] as BusterChatMessageReasoning_files)?.status
);
const file_ids = useMessageIndividual(
messageId,
(x) =>
(x?.reasoning_messages[reasoningMessageId] as BusterChatMessageReasoning_files)?.file_ids
);
const title = useMessageIndividual(
messageId,
(x) => (x?.reasoning_messages[reasoningMessageId] as BusterChatMessageReasoning_files)?.title
);
const secondary_title = useMessageIndividual(
messageId,
(x) =>
(x?.reasoning_messages[reasoningMessageId] as BusterChatMessageReasoning_files)
?.secondary_title
);
if (!title) return null;
2025-03-05 00:32:47 +08:00
return (
<BarContainer
showBar={true}
status={status}
isCompletedStream={isCompletedStream}
title={title}
secondaryTitle={secondary_title}
contentClassName="mb-2">
<div className="flex flex-col gap-3">
2025-03-06 04:14:24 +08:00
{file_ids.map((fileId) => (
2025-03-05 00:32:47 +08:00
<ReasoningMessage_File
2025-03-06 04:14:24 +08:00
key={fileId}
fileId={fileId}
2025-03-05 00:32:47 +08:00
chatId={chatId}
2025-03-06 04:14:24 +08:00
messageId={messageId}
reasoningMessageId={reasoningMessageId}
2025-03-05 00:32:47 +08:00
isCompletedStream={isCompletedStream}
/>
2025-03-06 04:14:24 +08:00
))}
2025-03-05 00:32:47 +08:00
</div>
</BarContainer>
);
}
);
ReasoningMessage_Files.displayName = 'ReasoningMessage_Files';