diff --git a/lightrag/api/__init__.py b/lightrag/api/__init__.py index f43e00be..c5bed57c 100644 --- a/lightrag/api/__init__.py +++ b/lightrag/api/__init__.py @@ -1 +1 @@ -__api_version__ = "0164" +__api_version__ = "0165" diff --git a/lightrag_webui/src/features/RetrievalTesting.tsx b/lightrag_webui/src/features/RetrievalTesting.tsx index 70ff2e7d..0744ae5e 100644 --- a/lightrag_webui/src/features/RetrievalTesting.tsx +++ b/lightrag_webui/src/features/RetrievalTesting.tsx @@ -12,6 +12,16 @@ import { EraserIcon, SendIcon } from 'lucide-react' import { useTranslation } from 'react-i18next' import type { QueryMode } from '@/api/lightrag' +// Helper function to generate unique IDs with browser compatibility +const generateUniqueId = () => { + // Use crypto.randomUUID() if available + if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') { + return crypto.randomUUID(); + } + // Fallback to timestamp + random string for browsers without crypto.randomUUID + return `id-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`; +}; + export default function RetrievalTesting() { const { t } = useTranslation() const [messages, setMessages] = useState(() => { @@ -108,13 +118,13 @@ export default function RetrievalTesting() { // Create messages // Save the original input (with prefix if any) in userMessage.content for display const userMessage: MessageWithError = { - id: crypto.randomUUID(), // Add unique ID + id: generateUniqueId(), // Use browser-compatible ID generation content: inputValue, role: 'user' } const assistantMessage: MessageWithError = { - id: crypto.randomUUID(), // Add unique ID + id: generateUniqueId(), // Use browser-compatible ID generation content: '', role: 'assistant', mermaidRendered: false