41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
// src/pages/api/ai/embeddings-status.ts - Updated
|
|
import type { APIRoute } from 'astro';
|
|
import { embeddingsService } from '../../../utils/embeddings.js';
|
|
|
|
export const prerender = false;
|
|
|
|
export const GET: APIRoute = async () => {
|
|
try {
|
|
await embeddingsService.waitForInitialization();
|
|
|
|
const stats = embeddingsService.getStats();
|
|
const status = stats.enabled && stats.initialized ? 'ready' :
|
|
stats.enabled && !stats.initialized ? 'initializing' : 'disabled';
|
|
|
|
console.log(`[EMBEDDINGS-STATUS-API] Service status: ${status}, stats:`, stats);
|
|
|
|
return new Response(JSON.stringify({
|
|
success: true,
|
|
embeddings: stats,
|
|
timestamp: new Date().toISOString(),
|
|
status: status
|
|
}), {
|
|
status: 200,
|
|
headers: { 'Content-Type': 'application/json' }
|
|
});
|
|
|
|
} catch (error) {
|
|
console.error('[EMBEDDINGS-STATUS-API] Error checking embeddings status:', error);
|
|
|
|
return new Response(JSON.stringify({
|
|
success: false,
|
|
embeddings: { enabled: false, initialized: false, count: 0 },
|
|
timestamp: new Date().toISOString(),
|
|
status: 'disabled',
|
|
error: error.message
|
|
}), {
|
|
status: 200,
|
|
headers: { 'Content-Type': 'application/json' }
|
|
});
|
|
}
|
|
}; |