mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-18 09:20: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,
|
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;
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue