// // SPDX-FileCopyrightText: Copyright (c) 1993-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. // SPDX-License-Identifier: Apache-2.0 // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // "use client" import { useState, useEffect } from "react" import { Button } from '@/components/ui/button' import { Badge } from '@/components/ui/badge' import { InfoIcon } from 'lucide-react' import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip' import { VectorDBStats } from '@/types/graph' interface PineconeConnectionProps { className?: string } export function PineconeConnection({ className }: PineconeConnectionProps) { const [connectionStatus, setConnectionStatus] = useState<"connected" | "disconnected" | "checking">("disconnected") const [error, setError] = useState(null) const [stats, setStats] = useState({ nodes: 0, relationships: 0, source: 'none' }) // Fetch vector DB stats const fetchStats = async () => { try { const response = await fetch('/api/pinecone-diag/stats'); const data = await response.json(); if (response.ok) { setStats({ nodes: typeof data.totalVectorCount === 'number' ? data.totalVectorCount : 0, relationships: 0, // Vector DB doesn't store relationships source: data.source || 'unknown', httpHealthy: data.httpHealthy }); // If we have a healthy HTTP connection, we're connected if (data.httpHealthy) { setConnectionStatus("connected"); setError(null); } else { setConnectionStatus("disconnected"); setError(data.error || 'Connection failed'); } console.log('Vector DB stats:', data); } else { console.error('Failed to fetch vector DB stats:', data); setConnectionStatus("disconnected"); setError(data.error || 'Failed to connect to vector database'); } } catch (error) { console.error('Error fetching vector DB stats:', error); setConnectionStatus("disconnected"); setError(error instanceof Error ? error.message : 'Error connecting to vector database'); } }; // Check connection status and stats const checkConnection = async () => { setConnectionStatus("checking") setError(null) try { await fetchStats(); // Fetch stats directly - our status is based on having embeddings } catch (error) { console.error('Error connecting to Vector DB:', error) setConnectionStatus("disconnected") setError(error instanceof Error ? error.message : 'Unknown error connecting to Vector DB') } } // Reset connection state const disconnect = async () => { setConnectionStatus("disconnected") setStats({ nodes: 0, relationships: 0, source: 'none' }) } // Initial connection check useEffect(() => { checkConnection() }, []) return (

Vector DB

Qdrant stores vector embeddings for semantic search

Status: {connectionStatus === "connected" ? ( Connected ) : connectionStatus === "checking" ? ( Checking... ) : ( Disconnected )}
{error && (

Error: {error}

{error.includes('404') && (

The Qdrant server is running but the collection doesn't exist yet.
Or using Docker Compose: docker compose restart qdrant

)}
)}
Qdrant {(stats as any).url || 'http://qdrant:6333'}
Vectors: {stats.nodes} indexed
{(stats as any).status && (
Status: {(stats as any).status}
)} {(stats as any).vectorSize && (
Dimensions: {(stats as any).vectorSize}d ({(stats as any).distance})
)}
{connectionStatus === "connected" && ( )}
) }