mirror of
https://github.com/ItzCrazyKns/Perplexica.git
synced 2025-06-19 16:28:42 +00:00
Removed compact mode
This commit is contained in:
@ -16,8 +16,6 @@ const Chat = ({
|
||||
setFileIds,
|
||||
files,
|
||||
setFiles,
|
||||
isCompact,
|
||||
setIsCompact,
|
||||
optimizationMode,
|
||||
setOptimizationMode,
|
||||
}: {
|
||||
@ -25,7 +23,6 @@ const Chat = ({
|
||||
sendMessage: (
|
||||
message: string,
|
||||
messageId?: string,
|
||||
options?: { isCompact?: boolean },
|
||||
) => void;
|
||||
loading: boolean;
|
||||
messageAppeared: boolean;
|
||||
@ -34,8 +31,6 @@ const Chat = ({
|
||||
setFileIds: (fileIds: string[]) => void;
|
||||
files: File[];
|
||||
setFiles: (files: File[]) => void;
|
||||
isCompact: boolean;
|
||||
setIsCompact: (isCompact: boolean) => void;
|
||||
optimizationMode: string;
|
||||
setOptimizationMode: (mode: string) => void;
|
||||
}) => {
|
||||
@ -89,7 +84,6 @@ const Chat = ({
|
||||
dividerRef={isLast ? dividerRef : undefined}
|
||||
isLast={isLast}
|
||||
rewrite={rewrite}
|
||||
isCompact={isCompact}
|
||||
sendMessage={sendMessage}
|
||||
/>
|
||||
{!isLast && msg.role === 'assistant' && (
|
||||
@ -112,8 +106,6 @@ const Chat = ({
|
||||
setFileIds={setFileIds}
|
||||
files={files}
|
||||
setFiles={setFiles}
|
||||
isCompact={isCompact}
|
||||
setIsCompact={setIsCompact}
|
||||
optimizationMode={optimizationMode}
|
||||
setOptimizationMode={setOptimizationMode}
|
||||
/>
|
||||
|
@ -282,20 +282,14 @@ const ChatWindow = ({ id }: { id?: string }) => {
|
||||
|
||||
const [focusMode, setFocusMode] = useState('webSearch');
|
||||
const [optimizationMode, setOptimizationMode] = useState('speed');
|
||||
const [isCompact, setIsCompact] = useState(false);
|
||||
|
||||
const [isMessagesLoaded, setIsMessagesLoaded] = useState(false);
|
||||
|
||||
const [notFound, setNotFound] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const savedCompactMode = localStorage.getItem('compactMode');
|
||||
const savedOptimizationMode = localStorage.getItem('optimizationMode');
|
||||
|
||||
if (savedCompactMode !== null) {
|
||||
setIsCompact(savedCompactMode === 'true');
|
||||
}
|
||||
|
||||
if (savedOptimizationMode !== null) {
|
||||
setOptimizationMode(savedOptimizationMode);
|
||||
} else {
|
||||
@ -346,7 +340,7 @@ const ChatWindow = ({ id }: { id?: string }) => {
|
||||
const sendMessage = async (
|
||||
message: string,
|
||||
messageId?: string,
|
||||
options?: { isCompact?: boolean; rewriteIndex?: number },
|
||||
options?: { rewriteIndex?: number },
|
||||
) => {
|
||||
if (loading) return;
|
||||
if (!isConfigReady) {
|
||||
@ -559,12 +553,12 @@ const sendMessage = async (
|
||||
const rewrite = (messageId: string) => {
|
||||
const messageIndex = messages.findIndex((msg) => msg.messageId === messageId);
|
||||
if(messageIndex == -1) return;
|
||||
sendMessage(messages[messageIndex - 1].content, messageId, { isCompact, rewriteIndex: messageIndex });
|
||||
sendMessage(messages[messageIndex - 1].content, messageId, { rewriteIndex: messageIndex });
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (isReady && initialMessage && isConfigReady) {
|
||||
sendMessage(initialMessage, undefined, { isCompact });
|
||||
sendMessage(initialMessage, undefined, { });
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [isConfigReady, isReady, initialMessage]);
|
||||
@ -604,8 +598,6 @@ const sendMessage = async (
|
||||
setFileIds={setFileIds}
|
||||
files={files}
|
||||
setFiles={setFiles}
|
||||
isCompact={isCompact}
|
||||
setIsCompact={setIsCompact}
|
||||
optimizationMode={optimizationMode}
|
||||
setOptimizationMode={setOptimizationMode}
|
||||
/>
|
||||
@ -621,8 +613,6 @@ const sendMessage = async (
|
||||
setFileIds={setFileIds}
|
||||
files={files}
|
||||
setFiles={setFiles}
|
||||
isCompact={isCompact}
|
||||
setIsCompact={setIsCompact}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
@ -14,8 +14,6 @@ const EmptyChat = ({
|
||||
setFileIds,
|
||||
files,
|
||||
setFiles,
|
||||
isCompact,
|
||||
setIsCompact,
|
||||
}: {
|
||||
sendMessage: (message: string) => void;
|
||||
focusMode: string;
|
||||
@ -26,8 +24,6 @@ const EmptyChat = ({
|
||||
setFileIds: (fileIds: string[]) => void;
|
||||
files: File[];
|
||||
setFiles: (files: File[]) => void;
|
||||
isCompact: boolean;
|
||||
setIsCompact: (isCompact: boolean) => void;
|
||||
}) => {
|
||||
const [isSettingsOpen, setIsSettingsOpen] = useState(false);
|
||||
|
||||
@ -52,8 +48,6 @@ const EmptyChat = ({
|
||||
setFileIds={setFileIds}
|
||||
files={files}
|
||||
setFiles={setFiles}
|
||||
isCompact={isCompact}
|
||||
setIsCompact={setIsCompact}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -17,13 +17,10 @@ const EmptyChatMessageInput = ({
|
||||
setFileIds,
|
||||
files,
|
||||
setFiles,
|
||||
isCompact,
|
||||
setIsCompact,
|
||||
}: {
|
||||
sendMessage: (
|
||||
message: string,
|
||||
messageId?: string,
|
||||
options?: { isCompact?: boolean },
|
||||
) => void;
|
||||
focusMode: string;
|
||||
setFocusMode: (mode: string) => void;
|
||||
@ -33,8 +30,6 @@ const EmptyChatMessageInput = ({
|
||||
setFileIds: (fileIds: string[]) => void;
|
||||
files: File[];
|
||||
setFiles: (files: File[]) => void;
|
||||
isCompact: boolean;
|
||||
setIsCompact: (isCompact: boolean) => void;
|
||||
}) => {
|
||||
const [copilotEnabled, setCopilotEnabled] = useState(false);
|
||||
const [message, setMessage] = useState('');
|
||||
@ -69,13 +64,13 @@ const EmptyChatMessageInput = ({
|
||||
<form
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
sendMessage(message, undefined, { isCompact });
|
||||
sendMessage(message, undefined);
|
||||
setMessage('');
|
||||
}}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter' && !e.shiftKey) {
|
||||
e.preventDefault();
|
||||
sendMessage(message, undefined, { isCompact });
|
||||
sendMessage(message, undefined);
|
||||
setMessage('');
|
||||
}
|
||||
}}
|
||||
@ -105,8 +100,6 @@ const EmptyChatMessageInput = ({
|
||||
<Optimization
|
||||
optimizationMode={optimizationMode}
|
||||
setOptimizationMode={setOptimizationMode}
|
||||
isCompact={isCompact}
|
||||
setIsCompact={setIsCompact}
|
||||
/>
|
||||
<button
|
||||
disabled={message.trim().length === 0}
|
||||
|
@ -33,7 +33,6 @@ const MessageBox = ({
|
||||
dividerRef,
|
||||
isLast,
|
||||
rewrite,
|
||||
isCompact,
|
||||
sendMessage,
|
||||
}: {
|
||||
message: Message;
|
||||
@ -43,11 +42,9 @@ const MessageBox = ({
|
||||
dividerRef?: MutableRefObject<HTMLDivElement | null>;
|
||||
isLast: boolean;
|
||||
rewrite: (messageId: string) => void;
|
||||
isCompact: boolean;
|
||||
sendMessage: (
|
||||
message: string,
|
||||
messageId?: string,
|
||||
options?: { isCompact?: boolean },
|
||||
messageId?: string
|
||||
) => void;
|
||||
}) => {
|
||||
const [parsedMessage, setParsedMessage] = useState(message.content);
|
||||
@ -114,7 +111,7 @@ const MessageBox = ({
|
||||
const { speechStatus, start, stop } = useSpeech({ text: speechMessage });
|
||||
|
||||
const handleSuggestionClick = (suggestion: string) => {
|
||||
sendMessage(suggestion, undefined, { isCompact });
|
||||
sendMessage(suggestion, undefined);
|
||||
};
|
||||
|
||||
const markdownOverrides: MarkdownToJSX.Options = {
|
||||
|
@ -15,23 +15,18 @@ const MessageInput = ({
|
||||
setFileIds,
|
||||
files,
|
||||
setFiles,
|
||||
isCompact,
|
||||
setIsCompact,
|
||||
optimizationMode,
|
||||
setOptimizationMode,
|
||||
}: {
|
||||
sendMessage: (
|
||||
message: string,
|
||||
messageId?: string,
|
||||
options?: { isCompact?: boolean },
|
||||
messageId?: string
|
||||
) => void;
|
||||
loading: boolean;
|
||||
fileIds: string[];
|
||||
setFileIds: (fileIds: string[]) => void;
|
||||
files: File[];
|
||||
setFiles: (files: File[]) => void;
|
||||
isCompact: boolean;
|
||||
setIsCompact: (isCompact: boolean) => void;
|
||||
optimizationMode: string;
|
||||
setOptimizationMode: (mode: string) => void;
|
||||
}) => {
|
||||
@ -73,13 +68,13 @@ const MessageInput = ({
|
||||
onSubmit={(e) => {
|
||||
if (loading) return;
|
||||
e.preventDefault();
|
||||
sendMessage(message, undefined, { isCompact });
|
||||
sendMessage(message, undefined);
|
||||
setMessage('');
|
||||
}}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter' && !e.shiftKey && !loading) {
|
||||
e.preventDefault();
|
||||
sendMessage(message, undefined, { isCompact });
|
||||
sendMessage(message, undefined);
|
||||
setMessage('');
|
||||
}
|
||||
}}
|
||||
@ -99,8 +94,6 @@ const MessageInput = ({
|
||||
<Optimization
|
||||
optimizationMode={optimizationMode}
|
||||
setOptimizationMode={setOptimizationMode}
|
||||
isCompact={isCompact}
|
||||
setIsCompact={setIsCompact}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
@ -140,8 +133,6 @@ const MessageInput = ({
|
||||
<Optimization
|
||||
optimizationMode={optimizationMode}
|
||||
setOptimizationMode={setOptimizationMode}
|
||||
isCompact={isCompact}
|
||||
setIsCompact={setIsCompact}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex flex-row items-center space-x-4">
|
||||
|
@ -35,28 +35,11 @@ const OptimizationModes = [
|
||||
|
||||
const Optimization = ({
|
||||
optimizationMode,
|
||||
setOptimizationMode,
|
||||
isCompact,
|
||||
setIsCompact,
|
||||
setOptimizationMode
|
||||
}: {
|
||||
optimizationMode: string;
|
||||
setOptimizationMode: (mode: string) => void;
|
||||
isCompact: boolean;
|
||||
setIsCompact: (isCompact: boolean) => void;
|
||||
}) => {
|
||||
useEffect(() => {
|
||||
const savedCompactMode = localStorage.getItem('compactMode');
|
||||
if (savedCompactMode === null) {
|
||||
localStorage.setItem('compactMode', String(isCompact));
|
||||
} else {
|
||||
setIsCompact(savedCompactMode === 'true');
|
||||
}
|
||||
}, [setIsCompact]);
|
||||
|
||||
const handleCompactChange = (checked: boolean) => {
|
||||
setIsCompact(checked);
|
||||
localStorage.setItem('compactMode', String(checked));
|
||||
};
|
||||
|
||||
const handleOptimizationChange = (mode: string) => {
|
||||
setOptimizationMode(mode);
|
||||
@ -70,12 +53,6 @@ const Optimization = ({
|
||||
className="p-2 text-black/50 dark:text-white/50 rounded-xl hover:bg-light-secondary dark:hover:bg-dark-secondary active:scale-95 transition duration-200 hover:text-black dark:hover:text-white"
|
||||
>
|
||||
<div className="flex flex-row items-center space-x-1">
|
||||
{isCompact && (
|
||||
<Minimize2
|
||||
size={16}
|
||||
className="text-gray-600 dark:text-gray-400"
|
||||
/>
|
||||
)}
|
||||
{
|
||||
OptimizationModes.find((mode) => mode.key === optimizationMode)
|
||||
?.icon
|
||||
@ -122,30 +99,6 @@ const Optimization = ({
|
||||
</p>
|
||||
</PopoverButton>
|
||||
))}
|
||||
<div className="border-t border-light-200 dark:border-dark-200 pt-2 mt-1">
|
||||
<label className="flex items-center space-x-2 p-2 rounded-lg cursor-pointer hover:bg-light-secondary dark:hover:bg-dark-secondary">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={isCompact}
|
||||
onChange={(e) => handleCompactChange(e.target.checked)}
|
||||
className="form-checkbox h-4 w-4 text-blue-600 transition duration-150 ease-in-out"
|
||||
/>
|
||||
<div className="flex items-center space-x-2">
|
||||
<Minimize2
|
||||
size={16}
|
||||
className="text-gray-600 dark:text-gray-400"
|
||||
/>
|
||||
<div>
|
||||
<p className="text-sm font-medium text-black dark:text-white">
|
||||
Compact Mode
|
||||
</p>
|
||||
<p className="text-xs text-black/70 dark:text-white/70">
|
||||
Generate more concise responses
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</PopoverPanel>
|
||||
</Transition>
|
||||
|
@ -8,8 +8,7 @@ import {
|
||||
} from './redditSearch';
|
||||
import {
|
||||
webSearchResponsePrompt,
|
||||
webSearchRetrieverPrompt,
|
||||
preciseWebSearchResponsePrompt,
|
||||
webSearchRetrieverPrompt
|
||||
} from './webSearch';
|
||||
import {
|
||||
wolframAlphaSearchResponsePrompt,
|
||||
@ -24,7 +23,6 @@ import {
|
||||
export default {
|
||||
webSearchResponsePrompt,
|
||||
webSearchRetrieverPrompt,
|
||||
preciseWebSearchResponsePrompt,
|
||||
academicSearchResponsePrompt,
|
||||
academicSearchRetrieverPrompt,
|
||||
redditSearchResponsePrompt,
|
||||
|
@ -107,42 +107,4 @@ export const webSearchResponsePrompt = `
|
||||
</context>
|
||||
|
||||
Current date & time in ISO format (UTC timezone) is: {date}.
|
||||
`;
|
||||
|
||||
export const preciseWebSearchResponsePrompt = `
|
||||
You are Perplexica, an AI model skilled in web search and crafting accurate, concise, and well-structured answers. You excel at breaking down long form content into brief summaries or specific answers.
|
||||
|
||||
Your task is to provide answers that are:
|
||||
- **Informative and relevant**: Precisely address the user's query using the given context.
|
||||
- **Well-structured**: Include clear headings and subheadings, and use a professional tone to present information concisely and logically.
|
||||
- **Cited and credible**: Use inline citations with [number] notation to refer to the context source(s) for each fact or detail included.
|
||||
- **Brief and Accurate**: If a direct answer is available, provide it succinctly without unnecessary elaboration.
|
||||
|
||||
### Formatting Instructions
|
||||
- **Structure**: Use a well-organized format with proper headings. Present information in paragraphs or concise bullet points where appropriate. You should never need more than one heading.
|
||||
- **Tone and Style**: Maintain a matter-of-fact tone and focus on delivering accurate information. Avoid overly complex language or unnecessary jargon.
|
||||
- **Markdown Usage**: Format your response with Markdown for clarity. Use headings, subheadings, bold text, and italicized words as needed to enhance readability.
|
||||
- **Length and Depth**: Be brief. Provide concise answers. Avoid superficial responses and strive for accuracy without unnecessary repetition.
|
||||
- **No main heading/title**: Start your response directly with the introduction unless asked to provide a specific title.
|
||||
- **Conclusion or Summary**: Do not include a conclusion unless the context specifically requires it.
|
||||
|
||||
### Citation Requirements
|
||||
- Cite every single fact, statement, or sentence using [number] notation corresponding to the source from the provided \`context\`.
|
||||
- Integrate citations naturally at the end of sentences or clauses as appropriate. For example, "The Eiffel Tower is one of the most visited landmarks in the world[1]."
|
||||
- Ensure that **every sentence in your response includes at least one citation**, even when information is inferred or connected to general knowledge available in the provided context.
|
||||
- Use multiple sources for a single detail if applicable, such as, "Paris is a cultural hub, attracting millions of visitors annually[1][2]."
|
||||
- Always prioritize credibility and accuracy by linking all statements back to their respective context sources.
|
||||
- Avoid citing unsupported assumptions or personal interpretations; if no source supports a statement, clearly indicate the limitation.
|
||||
|
||||
### Special Instructions
|
||||
- If the user provides vague input or if relevant information is missing, explain what additional details might help refine the search.
|
||||
- If no relevant information is found, say: "Hmm, sorry I could not find any relevant information on this topic. Would you like me to search again or ask something else?" Be transparent about limitations and suggest alternatives or ways to reframe the query.
|
||||
- Do not provide additional commentary or personal opinions unless specifically asked for in the context.
|
||||
- Do not include plesantries or greetings in your response.
|
||||
|
||||
<context>
|
||||
{context}
|
||||
</context>
|
||||
|
||||
Current date & time in ISO format (UTC timezone) is: {date}.
|
||||
`;
|
||||
`;
|
@ -6,7 +6,6 @@ export const searchHandlers: Record<string, MetaSearchAgent> = {
|
||||
activeEngines: [],
|
||||
queryGeneratorPrompt: prompts.webSearchRetrieverPrompt,
|
||||
responsePrompt: prompts.webSearchResponsePrompt,
|
||||
preciseResponsePrompt: prompts.preciseWebSearchResponsePrompt,
|
||||
rerank: true,
|
||||
rerankThreshold: 0.3,
|
||||
searchWeb: true,
|
||||
@ -16,7 +15,6 @@ export const searchHandlers: Record<string, MetaSearchAgent> = {
|
||||
activeEngines: ['arxiv', 'google scholar', 'pubmed'],
|
||||
queryGeneratorPrompt: prompts.academicSearchRetrieverPrompt,
|
||||
responsePrompt: prompts.academicSearchResponsePrompt,
|
||||
preciseResponsePrompt: prompts.academicSearchResponsePrompt,
|
||||
rerank: true,
|
||||
rerankThreshold: 0,
|
||||
searchWeb: true,
|
||||
@ -26,7 +24,6 @@ export const searchHandlers: Record<string, MetaSearchAgent> = {
|
||||
activeEngines: [],
|
||||
queryGeneratorPrompt: '',
|
||||
responsePrompt: prompts.writingAssistantPrompt,
|
||||
preciseResponsePrompt: prompts.writingAssistantPrompt,
|
||||
rerank: true,
|
||||
rerankThreshold: 0,
|
||||
searchWeb: false,
|
||||
@ -36,7 +33,6 @@ export const searchHandlers: Record<string, MetaSearchAgent> = {
|
||||
activeEngines: ['wolframalpha'],
|
||||
queryGeneratorPrompt: prompts.wolframAlphaSearchRetrieverPrompt,
|
||||
responsePrompt: prompts.wolframAlphaSearchResponsePrompt,
|
||||
preciseResponsePrompt: prompts.wolframAlphaSearchResponsePrompt,
|
||||
rerank: false,
|
||||
rerankThreshold: 0,
|
||||
searchWeb: true,
|
||||
@ -46,7 +42,6 @@ export const searchHandlers: Record<string, MetaSearchAgent> = {
|
||||
activeEngines: ['youtube'],
|
||||
queryGeneratorPrompt: prompts.youtubeSearchRetrieverPrompt,
|
||||
responsePrompt: prompts.youtubeSearchResponsePrompt,
|
||||
preciseResponsePrompt: prompts.youtubeSearchResponsePrompt,
|
||||
rerank: true,
|
||||
rerankThreshold: 0.3,
|
||||
searchWeb: true,
|
||||
@ -56,7 +51,6 @@ export const searchHandlers: Record<string, MetaSearchAgent> = {
|
||||
activeEngines: ['reddit'],
|
||||
queryGeneratorPrompt: prompts.redditSearchRetrieverPrompt,
|
||||
responsePrompt: prompts.redditSearchResponsePrompt,
|
||||
preciseResponsePrompt: prompts.redditSearchResponsePrompt,
|
||||
rerank: true,
|
||||
rerankThreshold: 0.3,
|
||||
searchWeb: true,
|
||||
|
@ -34,7 +34,6 @@ export interface MetaSearchAgentType {
|
||||
optimizationMode: 'speed' | 'balanced' | 'quality',
|
||||
fileIds: string[],
|
||||
systemInstructions: string,
|
||||
isCompact?: boolean,
|
||||
) => Promise<eventEmitter>;
|
||||
}
|
||||
|
||||
@ -45,7 +44,6 @@ interface Config {
|
||||
rerankThreshold: number;
|
||||
queryGeneratorPrompt: string;
|
||||
responsePrompt: string;
|
||||
preciseResponsePrompt: string;
|
||||
activeEngines: string[];
|
||||
}
|
||||
|
||||
@ -240,10 +238,7 @@ class MetaSearchAgent implements MetaSearchAgentType {
|
||||
embeddings: Embeddings,
|
||||
optimizationMode: 'speed' | 'balanced' | 'quality',
|
||||
systemInstructions: string,
|
||||
isCompact?: boolean,
|
||||
) {
|
||||
|
||||
console.log("compact mode", isCompact);
|
||||
console.log("optimization mode", optimizationMode);
|
||||
return RunnableSequence.from([
|
||||
RunnableMap.from({
|
||||
@ -290,9 +285,7 @@ class MetaSearchAgent implements MetaSearchAgentType {
|
||||
ChatPromptTemplate.fromMessages([
|
||||
[
|
||||
'system',
|
||||
isCompact
|
||||
? this.config.preciseResponsePrompt
|
||||
: this.config.responsePrompt,
|
||||
this.config.responsePrompt
|
||||
],
|
||||
new MessagesPlaceholder('chat_history'),
|
||||
['user', '{query}'],
|
||||
@ -483,7 +476,6 @@ class MetaSearchAgent implements MetaSearchAgentType {
|
||||
optimizationMode: 'speed' | 'balanced' | 'quality',
|
||||
fileIds: string[],
|
||||
systemInstructions: string,
|
||||
isCompact?: boolean,
|
||||
) {
|
||||
const emitter = new eventEmitter();
|
||||
|
||||
@ -492,8 +484,7 @@ class MetaSearchAgent implements MetaSearchAgentType {
|
||||
fileIds,
|
||||
embeddings,
|
||||
optimizationMode,
|
||||
systemInstructions,
|
||||
isCompact,
|
||||
systemInstructions
|
||||
);
|
||||
|
||||
const stream = answeringChain.streamEvents(
|
||||
|
Reference in New Issue
Block a user