mirror of
https://github.com/ItzCrazyKns/Perplexica.git
synced 2025-09-18 23:31:33 +00:00
feat(UI): Add the search query to the response.
Also, tweaked the search retriever prompt so it gives better search queries.
This commit is contained in:
@@ -27,6 +27,7 @@ export type Message = {
|
||||
suggestions?: string[];
|
||||
sources?: Document[];
|
||||
modelStats?: ModelStats;
|
||||
searchQuery?: string;
|
||||
};
|
||||
|
||||
export interface File {
|
||||
@@ -416,6 +417,7 @@ const ChatWindow = ({ id }: { id?: string }) => {
|
||||
|
||||
if (data.type === 'sources') {
|
||||
sources = data.data;
|
||||
const searchQuery = data.searchQuery;
|
||||
if (!added) {
|
||||
setMessages((prevMessages) => [
|
||||
...prevMessages,
|
||||
@@ -425,6 +427,7 @@ const ChatWindow = ({ id }: { id?: string }) => {
|
||||
chatId: chatId!,
|
||||
role: 'assistant',
|
||||
sources: sources,
|
||||
searchQuery: searchQuery,
|
||||
createdAt: new Date(),
|
||||
},
|
||||
]);
|
||||
@@ -481,6 +484,8 @@ const ChatWindow = ({ id }: { id?: string }) => {
|
||||
...message,
|
||||
// Include model stats if available, otherwise null
|
||||
modelStats: data.modelStats || null,
|
||||
// Make sure the searchQuery is preserved (if available in the message data)
|
||||
searchQuery: message.searchQuery || data.searchQuery,
|
||||
};
|
||||
}
|
||||
return message;
|
||||
|
@@ -278,6 +278,12 @@ const MessageBox = ({
|
||||
Sources
|
||||
</h3>
|
||||
</div>
|
||||
{message.searchQuery && (
|
||||
<div className="mb-2 text-sm bg-light-secondary dark:bg-dark-secondary rounded-lg p-3">
|
||||
<span className="font-medium text-black/70 dark:text-white/70">Search query:</span>{' '}
|
||||
<span className="text-black dark:text-white">{message.searchQuery}</span>
|
||||
</div>
|
||||
)}
|
||||
<MessageSources sources={message.sources} />
|
||||
</div>
|
||||
)}
|
||||
|
Reference in New Issue
Block a user