mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-16 16:30:15 +01:00
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:
parent
b8fa8eb316
commit
f8bb0d955d
2 changed files with 13 additions and 7 deletions
|
|
@ -7,10 +7,11 @@ import type {
|
|||
Agents,
|
||||
} from 'librechat-data-provider';
|
||||
import { MessageContext, SearchContext } from '~/Providers';
|
||||
import { EditTextPart, EmptyText } from './Parts';
|
||||
import MemoryArtifacts from './MemoryArtifacts';
|
||||
import Sources from '~/components/Web/Sources';
|
||||
import { mapAttachments } from '~/utils/map';
|
||||
import { EditTextPart } from './Parts';
|
||||
import Container from './Container';
|
||||
import Part from './Part';
|
||||
|
||||
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 (
|
||||
<>
|
||||
<SearchContext.Provider value={{ searchResults }}>
|
||||
<MemoryArtifacts attachments={attachments} />
|
||||
<Sources messageId={messageId} conversationId={conversationId || undefined} />
|
||||
{showEmptyCursor && (
|
||||
<Container>
|
||||
<EmptyText />
|
||||
</Container>
|
||||
)}
|
||||
{content.map((part, idx) => {
|
||||
if (!part) {
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -295,12 +295,9 @@ export default function useChatFunctions({
|
|||
},
|
||||
];
|
||||
} else {
|
||||
initialResponse.content = [
|
||||
{
|
||||
type: ContentTypes.TEXT,
|
||||
text: '',
|
||||
},
|
||||
];
|
||||
// Don't pre-initialize content type - let incoming delta events
|
||||
// create content parts dynamically (supports think, text, etc.)
|
||||
initialResponse.content = [];
|
||||
}
|
||||
}
|
||||
setShowStopButton(true);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue