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

41 lines
1.3 KiB
TypeScript
Raw Normal View History

2025-03-05 00:32:47 +08:00
import React from 'react';
import type { ReasoningMessageProps } from '../ReasoningMessageSelector';
2025-03-06 06:51:35 +08:00
import type {
BusterChatMessageReasoning_files,
BusterChatMessage
} from '@/api/asset_interfaces/chat';
2025-03-05 00:32:47 +08:00
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
2025-03-06 06:51:35 +08:00
const getReasoningMessage = (x: BusterChatMessage | undefined, reasoningMessageId: string) =>
x?.reasoning_messages[reasoningMessageId] as BusterChatMessageReasoning_files;
2025-03-05 00:32:47 +08:00
export const ReasoningMessage_Files: React.FC<ReasoningMessageProps> = React.memo(
2025-03-08 10:18:22 +08:00
({ isCompletedStream, chatId, reasoningMessageId, messageId }) => {
2025-03-06 06:49:46 +08:00
const file_ids = useMessageIndividual(
messageId,
2025-03-06 06:51:35 +08:00
(x) => getReasoningMessage(x, reasoningMessageId)?.file_ids
2025-03-06 06:49:46 +08:00
);
2025-03-05 00:32:47 +08:00
2025-03-08 12:46:22 +08:00
if (!file_ids || file_ids.length === 0) return null;
2025-03-08 12:30:12 +08:00
2025-03-05 00:32:47 +08:00
return (
2025-03-08 10:18:22 +08:00
<div className="flex flex-col gap-3">
{file_ids.map((fileId) => (
<ReasoningMessage_File
key={fileId}
fileId={fileId}
chatId={chatId}
messageId={messageId}
reasoningMessageId={reasoningMessageId}
isCompletedStream={isCompletedStream}
/>
))}
</div>
2025-03-05 00:32:47 +08:00
);
}
);
ReasoningMessage_Files.displayName = 'ReasoningMessage_Files';