fix: remove thinking tag on projects list message history
This commit is contained in:
parent
54d17c9c72
commit
1c9890649d
@ -3,6 +3,7 @@ import { create } from 'zustand'
|
|||||||
import { RenderMarkdown } from './RenderMarkdown'
|
import { RenderMarkdown } from './RenderMarkdown'
|
||||||
import { useAppState } from '@/hooks/useAppState'
|
import { useAppState } from '@/hooks/useAppState'
|
||||||
import { useTranslation } from '@/i18n/react-i18next-compat'
|
import { useTranslation } from '@/i18n/react-i18next-compat'
|
||||||
|
import { extractThinkingContent } from '@/lib/utils'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
text: string
|
text: string
|
||||||
@ -43,19 +44,6 @@ const ThinkingBlock = ({ id, text }: Props) => {
|
|||||||
setThinkingState(id, newExpandedState)
|
setThinkingState(id, newExpandedState)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract thinking content from either format
|
|
||||||
const extractThinkingContent = (text: string) => {
|
|
||||||
return text
|
|
||||||
.replace(/<\/?think>/g, '')
|
|
||||||
.replace(/<\|channel\|>analysis<\|message\|>/g, '')
|
|
||||||
.replace(/<\|start\|>assistant<\|channel\|>final<\|message\|>/g, '')
|
|
||||||
.replace(/assistant<\|channel\|>final<\|message\|>/g, '')
|
|
||||||
.replace(/<\|channel\|>/g, '') // remove any remaining channel markers
|
|
||||||
.replace(/<\|message\|>/g, '') // remove any remaining message markers
|
|
||||||
.replace(/<\|start\|>/g, '') // remove any remaining start markers
|
|
||||||
.trim()
|
|
||||||
}
|
|
||||||
|
|
||||||
const thinkingContent = extractThinkingContent(text)
|
const thinkingContent = extractThinkingContent(text)
|
||||||
if (!thinkingContent) return null
|
if (!thinkingContent) return null
|
||||||
|
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import { useThreads } from '@/hooks/useThreads'
|
|||||||
import { useThreadManagement } from '@/hooks/useThreadManagement'
|
import { useThreadManagement } from '@/hooks/useThreadManagement'
|
||||||
import { useLeftPanel } from '@/hooks/useLeftPanel'
|
import { useLeftPanel } from '@/hooks/useLeftPanel'
|
||||||
import { useMessages } from '@/hooks/useMessages'
|
import { useMessages } from '@/hooks/useMessages'
|
||||||
import { cn } from '@/lib/utils'
|
import { cn, extractThinkingContent } from '@/lib/utils'
|
||||||
import { useSmallScreen } from '@/hooks/useMediaQuery'
|
import { useSmallScreen } from '@/hooks/useMediaQuery'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -167,14 +167,10 @@ const SortableItem = memo(
|
|||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<span>{thread.title || t('common:newThread')}</span>
|
<span>{thread.title || t('common:newThread')}</span>
|
||||||
{variant === 'project' && (
|
|
||||||
<>
|
|
||||||
{variant === 'project' && getLastMessageInfo?.content && (
|
{variant === 'project' && getLastMessageInfo?.content && (
|
||||||
<div className="text-sm text-main-view-fg/60 mt-0.5 line-clamp-2">
|
<span className="block text-sm text-main-view-fg/60 mt-0.5 truncate">
|
||||||
{getLastMessageInfo.content}
|
{extractThinkingContent(getLastMessageInfo.content)}
|
||||||
</div>
|
</span>
|
||||||
)}
|
|
||||||
</>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center">
|
<div className="flex items-center">
|
||||||
|
|||||||
@ -165,3 +165,15 @@ export function formatDuration(startTime: number, endTime?: number): string {
|
|||||||
export function sanitizeModelId(modelId: string): string {
|
export function sanitizeModelId(modelId: string): string {
|
||||||
return modelId.replace(/[^a-zA-Z0-9/_\-.]/g, '').replace(/\./g, '_')
|
return modelId.replace(/[^a-zA-Z0-9/_\-.]/g, '').replace(/\./g, '_')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const extractThinkingContent = (text: string) => {
|
||||||
|
return text
|
||||||
|
.replace(/<\/?think>/g, '')
|
||||||
|
.replace(/<\|channel\|>analysis<\|message\|>/g, '')
|
||||||
|
.replace(/<\|start\|>assistant<\|channel\|>final<\|message\|>/g, '')
|
||||||
|
.replace(/assistant<\|channel\|>final<\|message\|>/g, '')
|
||||||
|
.replace(/<\|channel\|>/g, '') // remove any remaining channel markers
|
||||||
|
.replace(/<\|message\|>/g, '') // remove any remaining message markers
|
||||||
|
.replace(/<\|start\|>/g, '') // remove any remaining start markers
|
||||||
|
.trim()
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user