fix: Allow dynamic content creation in useChatFunctions

- Updated the initial response handling to avoid pre-initializing content types, enabling dynamic creation of content parts based on incoming delta events. This change supports various content types such as think and text.
This commit is contained in:
Danny Avila 2025-12-12 02:11:12 -05:00
parent b8fa8eb316
commit f8bb0d955d
No known key found for this signature in database
GPG key ID: BF31EEB2C5CA0956
2 changed files with 13 additions and 7 deletions

View file

@ -7,10 +7,11 @@ import type {
Agents, Agents,
} from 'librechat-data-provider'; } from 'librechat-data-provider';
import { MessageContext, SearchContext } from '~/Providers'; import { MessageContext, SearchContext } from '~/Providers';
import { EditTextPart, EmptyText } from './Parts';
import MemoryArtifacts from './MemoryArtifacts'; import MemoryArtifacts from './MemoryArtifacts';
import Sources from '~/components/Web/Sources'; import Sources from '~/components/Web/Sources';
import { mapAttachments } from '~/utils/map'; import { mapAttachments } from '~/utils/map';
import { EditTextPart } from './Parts'; import Container from './Container';
import Part from './Part'; import Part from './Part';
type ContentPartsProps = { type ContentPartsProps = {
@ -95,11 +96,19 @@ const ContentParts = memo(
); );
} }
/** Show cursor placeholder when content is empty but actively submitting */
const showEmptyCursor = content.length === 0 && effectiveIsSubmitting;
return ( return (
<> <>
<SearchContext.Provider value={{ searchResults }}> <SearchContext.Provider value={{ searchResults }}>
<MemoryArtifacts attachments={attachments} /> <MemoryArtifacts attachments={attachments} />
<Sources messageId={messageId} conversationId={conversationId || undefined} /> <Sources messageId={messageId} conversationId={conversationId || undefined} />
{showEmptyCursor && (
<Container>
<EmptyText />
</Container>
)}
{content.map((part, idx) => { {content.map((part, idx) => {
if (!part) { if (!part) {
return null; return null;

View file

@ -295,12 +295,9 @@ export default function useChatFunctions({
}, },
]; ];
} else { } else {
initialResponse.content = [ // Don't pre-initialize content type - let incoming delta events
{ // create content parts dynamically (supports think, text, etc.)
type: ContentTypes.TEXT, initialResponse.content = [];
text: '',
},
];
} }
} }
setShowStopButton(true); setShowStopButton(true);