Bump webui setting version to 12

This commit is contained in:
yangdx
2025-04-29 02:36:17 +08:00
parent b6f4177af5
commit 4e2e668def
2 changed files with 32 additions and 11 deletions

View File

@@ -15,16 +15,33 @@ import type { QueryMode } from '@/api/lightrag'
export default function RetrievalTesting() { export default function RetrievalTesting() {
const { t } = useTranslation() const { t } = useTranslation()
const [messages, setMessages] = useState<MessageWithError[]>(() => { const [messages, setMessages] = useState<MessageWithError[]>(() => {
const history = useSettingsStore.getState().retrievalHistory || [] try {
// Ensure each message from history has a unique ID and mermaidRendered status const history = useSettingsStore.getState().retrievalHistory || []
return history.map((msg, index) => { // Ensure each message from history has a unique ID and mermaidRendered status
const msgWithError = msg as MessageWithError // Cast to access potential properties return history.map((msg, index) => {
return { try {
...msg, const msgWithError = msg as MessageWithError // Cast to access potential properties
id: msgWithError.id || `hist-${Date.now()}-${index}`, // Add ID if missing return {
mermaidRendered: msgWithError.mermaidRendered ?? true // Assume historical mermaid is rendered ...msg,
} id: msgWithError.id || `hist-${Date.now()}-${index}`, // Add ID if missing
}) mermaidRendered: msgWithError.mermaidRendered ?? true // Assume historical mermaid is rendered
}
} catch (error) {
console.error('Error processing message:', error)
// Return a default message if there's an error
return {
role: 'system',
content: 'Error loading message',
id: `error-${Date.now()}-${index}`,
isError: true,
mermaidRendered: true
}
}
})
} catch (error) {
console.error('Error loading history:', error)
return [] // Return an empty array if there's an error
}
}) })
const [inputValue, setInputValue] = useState('') const [inputValue, setInputValue] = useState('')
const [isLoading, setIsLoading] = useState(false) const [isLoading, setIsLoading] = useState(false)

View File

@@ -167,7 +167,7 @@ const useSettingsStoreBase = create<SettingsState>()(
{ {
name: 'settings-storage', name: 'settings-storage',
storage: createJSONStorage(() => localStorage), storage: createJSONStorage(() => localStorage),
version: 11, version: 12,
migrate: (state: any, version: number) => { migrate: (state: any, version: number) => {
if (version < 2) { if (version < 2) {
state.showEdgeLabel = false state.showEdgeLabel = false
@@ -221,6 +221,10 @@ const useSettingsStoreBase = create<SettingsState>()(
state.minEdgeSize = 1 state.minEdgeSize = 1
state.maxEdgeSize = 1 state.maxEdgeSize = 1
} }
if (version < 12) {
// Clear retrieval history to avoid compatibility issues with MessageWithError type
state.retrievalHistory = []
}
return state return state
} }
} }