mirror of
https://github.com/ItzCrazyKns/Perplexica.git
synced 2025-09-18 07:11:34 +00:00
refactor: remove unused deepseekChat.ts in favor
of reasoningChatModel.ts and messageProcessor.ts in favor of alternaitngMessageValidator.ts - Removed src/lib/deepseekChat.ts as it was duplicative - All functionality is now handled by reasoningChatModel.ts - No imports or references to deepseekChat.ts found in codebase - Removed src/utils/messageProcessor.ts as it was duplicative - All functionality is now handled by alternatingMessaageValidator.ts - No imports or references messageProcessor.ts found in codebase
This commit is contained in:
@@ -35,7 +35,6 @@ const BatchDeleteChats = ({
|
||||
|
||||
setLoading(true);
|
||||
try {
|
||||
// Delete chats one by one
|
||||
for (const chatId of chatIds) {
|
||||
await fetch(`${process.env.NEXT_PUBLIC_API_URL}/chats/${chatId}`, {
|
||||
method: 'DELETE',
|
||||
@@ -45,7 +44,6 @@ const BatchDeleteChats = ({
|
||||
});
|
||||
}
|
||||
|
||||
// Update local state
|
||||
const newChats = chats.filter(chat => !chatIds.includes(chat.id));
|
||||
setChats(newChats);
|
||||
|
||||
|
@@ -39,11 +39,11 @@ const useSocket = (
|
||||
const retryCountRef = useRef(0);
|
||||
const isCleaningUpRef = useRef(false);
|
||||
const MAX_RETRIES = 3;
|
||||
const INITIAL_BACKOFF = 1000; // 1 second
|
||||
const INITIAL_BACKOFF = 1000;
|
||||
const isConnectionErrorRef = useRef(false);
|
||||
|
||||
const getBackoffDelay = (retryCount: number) => {
|
||||
return Math.min(INITIAL_BACKOFF * Math.pow(2, retryCount), 10000); // Cap at 10 seconds
|
||||
return Math.min(INITIAL_BACKOFF * Math.pow(2, retryCount), 10000);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
|
@@ -16,15 +16,8 @@ const ReasoningPanel = ({ thinking, className, isExpanded: propExpanded }: Reaso
|
||||
const [isExpanded, setIsExpanded] = React.useState(true);
|
||||
const [detailsRefs, setDetailsRefs] = React.useState<HTMLDetailsElement[]>([]);
|
||||
|
||||
logger.info('ReasoningPanel rendering with:', {
|
||||
thinking: thinking,
|
||||
isExpanded: propExpanded,
|
||||
detailsRefsCount: detailsRefs.length
|
||||
});
|
||||
|
||||
React.useEffect(() => {
|
||||
if (propExpanded !== undefined) {
|
||||
logger.info('Updating expansion state:', propExpanded);
|
||||
setIsExpanded(propExpanded);
|
||||
}
|
||||
}, [propExpanded]);
|
||||
@@ -33,7 +26,6 @@ const ReasoningPanel = ({ thinking, className, isExpanded: propExpanded }: Reaso
|
||||
if (element) {
|
||||
setDetailsRefs(refs => {
|
||||
if (!refs.includes(element)) {
|
||||
logger.info('Adding new details ref');
|
||||
return [...refs, element];
|
||||
}
|
||||
return refs;
|
||||
@@ -42,11 +34,9 @@ const ReasoningPanel = ({ thinking, className, isExpanded: propExpanded }: Reaso
|
||||
}, []);
|
||||
|
||||
const expandAll = () => {
|
||||
logger.info('Expanding all details');
|
||||
detailsRefs.forEach(ref => ref.open = true);
|
||||
};
|
||||
const collapseAll = () => {
|
||||
logger.info('Collapsing all details');
|
||||
detailsRefs.forEach(ref => ref.open = false);
|
||||
};
|
||||
|
||||
@@ -73,9 +63,7 @@ const ReasoningPanel = ({ thinking, className, isExpanded: propExpanded }: Reaso
|
||||
{thinking.split('\n\n').map((paragraph, index) => {
|
||||
if (!paragraph.trim()) return null;
|
||||
|
||||
// Extract content without the bullet prefix
|
||||
const content = paragraph.replace(/^[•\-\d.]\s*/, '');
|
||||
logger.info(`Processing paragraph ${index}:`, content);
|
||||
|
||||
return (
|
||||
<div key={index} className="mb-2 last:mb-0">
|
||||
@@ -117,4 +105,4 @@ const ReasoningPanel = ({ thinking, className, isExpanded: propExpanded }: Reaso
|
||||
);
|
||||
};
|
||||
|
||||
export default ReasoningPanel;
|
||||
export default ReasoningPanel;
|
||||
|
@@ -47,34 +47,21 @@ const MessageBox = ({
|
||||
const [isThinkingExpanded, setIsThinkingExpanded] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
logger.info(`Processing message:`, {
|
||||
content: message.content,
|
||||
role: message.role,
|
||||
messageId: message.messageId
|
||||
});
|
||||
|
||||
const regex = /\[(\d+)\]/g;
|
||||
const thinkRegex = /<think>(.*?)(?:<\/think>|$)(.*)/s;
|
||||
|
||||
// Check for thinking content, including partial tags
|
||||
const match = message.content.match(thinkRegex);
|
||||
logger.info(`Think tag match:`, match);
|
||||
|
||||
if (match) {
|
||||
const [_, thinkingContent, answerContent] = match;
|
||||
|
||||
// Set thinking content even if </think> hasn't appeared yet
|
||||
if (thinkingContent) {
|
||||
logger.info(`Found thinking content:`, thinkingContent.trim());
|
||||
setThinking(thinkingContent.trim());
|
||||
setIsThinkingExpanded(true); // Expand when thinking starts
|
||||
setIsThinkingExpanded(true);
|
||||
}
|
||||
|
||||
// Only set answer content if we have it (after </think>)
|
||||
if (answerContent) {
|
||||
logger.info(`Found answer content:`, answerContent.trim());
|
||||
setIsThinkingExpanded(false); // Collapse when thinking is done
|
||||
// Process the answer part for sources if needed
|
||||
setIsThinkingExpanded(false);
|
||||
if (message.role === 'assistant' && message?.sources && message.sources.length > 0) {
|
||||
setParsedMessage(
|
||||
answerContent.trim().replace(
|
||||
@@ -89,7 +76,6 @@ const MessageBox = ({
|
||||
setSpeechMessage(answerContent.trim().replace(regex, ''));
|
||||
}
|
||||
} else {
|
||||
// No thinking content - process as before
|
||||
if (message.role === 'assistant' && message?.sources && message.sources.length > 0) {
|
||||
setParsedMessage(
|
||||
message.content.replace(
|
||||
|
Reference in New Issue
Block a user