LibreChat/client/src/components/Chat/Messages/Content/ContentParts.tsx
Danny Avila 388dc1789b
🛠️ fix: RunManager, AssistantService and useContentHandler Issues (#1920)
* fix(useContentHandler): retain undefined parts and handle them within `ContentParts` rendering

* fix(AssistantService/in_progress): skip empty messages

* refactor(RunManager): create highly specific `seenSteps` Set keys for RunSteps with use of `getDetailsSignature` and `getToolCallSignature`,to ensure changes from polling are always captured
2024-02-28 15:15:45 -05:00

50 lines
1.2 KiB
TypeScript

import { Suspense } from 'react';
import type { TMessageContentParts } from 'librechat-data-provider';
import { UnfinishedMessage } from './MessageContent';
import { DelayedRender } from '~/components/ui';
import Part from './Part';
const ContentParts = ({
error,
unfinished,
isSubmitting,
isLast,
content,
...props
}: // eslint-disable-next-line @typescript-eslint/no-explicit-any
any) => {
if (error) {
// return <ErrorMessage text={text} />;
} else {
const { message } = props;
const { messageId } = message;
return (
<>
{content.map((part: TMessageContentParts | undefined, idx: number) => {
if (!part) {
return null;
}
return (
<Part
key={`display-${messageId}-${idx}`}
showCursor={idx === content.length - 1 && isLast}
isSubmitting={isSubmitting}
part={part}
{...props}
/>
);
})}
{!isSubmitting && unfinished && (
<Suspense>
<DelayedRender delay={250}>
<UnfinishedMessage key={`unfinished-${messageId}`} />
</DelayedRender>
</Suspense>
)}
</>
);
}
};
export default ContentParts;