mirror of
https://github.com/ItzCrazyKns/Perplexica.git
synced 2025-10-13 19:18:14 +00:00
feat(chat-hook): get suggestions when sources is > 0
This commit is contained in:
@@ -686,15 +686,15 @@ export const ChatProvider = ({
|
|||||||
(msg) => msg.messageId === messageId && msg.role === 'user',
|
(msg) => msg.messageId === messageId && msg.role === 'user',
|
||||||
);
|
);
|
||||||
|
|
||||||
const sourceMessageIndex = messagesRef.current.findIndex(
|
const sourceMessage = messagesRef.current.find(
|
||||||
(msg, i) => i > userMessageIndex && msg.role === 'source',
|
(msg, i) => i > userMessageIndex && msg.role === 'source',
|
||||||
);
|
) as SourceMessage | undefined;
|
||||||
|
|
||||||
const suggestionMessageIndex = messagesRef.current.findIndex(
|
const suggestionMessageIndex = messagesRef.current.findIndex(
|
||||||
(msg, i) => i > userMessageIndex && msg.role === 'suggestion',
|
(msg, i) => i > userMessageIndex && msg.role === 'suggestion',
|
||||||
);
|
);
|
||||||
|
|
||||||
if (sourceMessageIndex != -1 && suggestionMessageIndex == -1) {
|
if (sourceMessage && sourceMessage.sources.length > 0 && suggestionMessageIndex == -1) {
|
||||||
const suggestions = await getSuggestions(messagesRef.current);
|
const suggestions = await getSuggestions(messagesRef.current);
|
||||||
setMessages((prev) => {
|
setMessages((prev) => {
|
||||||
return [
|
return [
|
||||||
|
Reference in New Issue
Block a user