Files
openclaw/scripts/docs-chat/api/health.ts
Buns Enchantress 4b42a54452 feat: integrate Upstash Vector for enhanced document retrieval in chat API
- Implemented Upstash Vector as a cloud-based storage solution for document chunks, replacing the local LanceDB option.
- Added auto-detection of storage mode based on environment variables for seamless integration.
- Updated the chat API to utilize the new retrieval mechanism, enhancing response accuracy and performance.
- Enhanced README with setup instructions for Upstash and updated environment variable requirements.
- Introduced new scripts and configurations for managing the vector index and API interactions.
2026-02-03 04:39:04 -06:00

41 lines
1.1 KiB
TypeScript

/**
* Health check endpoint for docs-chat API.
*/
import type { VercelRequest, VercelResponse } from "@vercel/node";
import { DocsStore } from "../rag/store-upstash.js";
const corsHeaders: Record<string, string> = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, OPTIONS",
"Access-Control-Allow-Headers": "Content-Type",
};
export default async function handler(req: VercelRequest, res: VercelResponse) {
// Handle CORS preflight
if (req.method === "OPTIONS") {
Object.entries(corsHeaders).forEach(([key, value]) => {
res.setHeader(key, value);
});
res.status(204).end();
return;
}
if (req.method !== "GET") {
res.status(405).json({ error: "Method not allowed" });
return;
}
try {
const store = new DocsStore();
const count = await store.count();
Object.entries(corsHeaders).forEach(([key, value]) => {
res.setHeader(key, value);
});
res.status(200).json({ ok: true, chunks: count, mode: "upstash-vector" });
} catch (err) {
console.error("Health check error:", err);
res.status(500).json({ ok: false, error: "Failed to connect to vector store" });
}
}