2025-10-06 17:05:41 +00:00
|
|
|
import { NextRequest, NextResponse } from 'next/server';
|
2025-10-25 06:16:44 +00:00
|
|
|
import { QdrantService } from '@/lib/qdrant';
|
2025-10-06 17:05:41 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Clear all data from the Pinecone vector database
|
|
|
|
|
* POST /api/pinecone-diag/clear
|
|
|
|
|
*/
|
|
|
|
|
export async function POST() {
|
|
|
|
|
// Get the Pinecone service instance
|
2025-10-25 06:16:44 +00:00
|
|
|
const pineconeService = QdrantService.getInstance();
|
2025-10-06 17:05:41 +00:00
|
|
|
|
|
|
|
|
// Clear all vectors from the database
|
|
|
|
|
const deleteSuccess = await pineconeService.deleteAllEntities();
|
|
|
|
|
|
|
|
|
|
// Get updated stats after clearing
|
|
|
|
|
const stats = await pineconeService.getStats();
|
|
|
|
|
|
|
|
|
|
// Return response based on operation success
|
|
|
|
|
return NextResponse.json({
|
|
|
|
|
success: deleteSuccess,
|
|
|
|
|
message: deleteSuccess
|
|
|
|
|
? 'Successfully cleared all data from Pinecone vector database'
|
|
|
|
|
: 'Failed to clear Pinecone database - service may not be available',
|
|
|
|
|
totalVectorCount: stats.totalVectorCount || 0,
|
|
|
|
|
httpHealthy: stats.httpHealthy || false
|
|
|
|
|
});
|
|
|
|
|
}
|