dgx-spark-playbooks/nvidia/txt2kg/assets/frontend/app/api/pinecone-diag/stats/route.ts
Santosh Bhavani de9c46e97e Replace Pinecone with Qdrant for ARM64 compatibility
- Migrate from Pinecone to Qdrant vector database for native ARM64 support
- Add Qdrant service with automatic collection initialization in docker-compose
- Implement QdrantService with UUID-based point IDs to meet Qdrant requirements
- Update all API routes and frontend components to use Qdrant
- Enhance Storage Connections UI with detailed stats (vectors, status, dimensions)
- Add icons and tooltips to Vector DB section matching Graph DB UX
2025-10-24 23:16:44 -07:00

42 lines
1.3 KiB
TypeScript

import { NextRequest, NextResponse } from 'next/server';
import { QdrantService } from '@/lib/qdrant';
/**
* Get Pinecone vector database stats
*/
export async function GET() {
try {
// Initialize Pinecone service
const pineconeService = QdrantService.getInstance();
// We can now directly call getStats() which handles initialization and error recovery
const stats = await pineconeService.getStats();
return NextResponse.json({
...stats,
timestamp: new Date().toISOString()
});
} catch (error) {
console.error('Error getting Pinecone stats:', error);
// Return a successful response with error information
// This prevents the UI from breaking when Pinecone is unavailable
let errorMessage = error instanceof Error ? error.message : String(error);
// More specific error message for 404 errors
if (errorMessage.includes('404')) {
errorMessage = 'Pinecone server returned 404. The server may not be running or the index does not exist.';
}
return NextResponse.json(
{
error: `Failed to get Pinecone stats: ${errorMessage}`,
totalVectorCount: 0,
source: 'error',
httpHealthy: false,
timestamp: new Date().toISOString()
},
{ status: 200 } // Use 200 instead of 500 to avoid UI errors
);
}
}