| 1234567891011121314151617181920212223 |
- import { Router } from "express";
- import { z } from "zod";
- import { searchDocs } from "../chat/searchChat.js";
- export const searchRouter = Router();
- const searchBodySchema = z.object({
- query: z.string().min(1),
- topK: z.number().int().positive().optional()
- });
- searchRouter.post("/", async (req, res, next) => {
- try {
- const body = searchBodySchema.parse(req.body);
- const results = await searchDocs({
- query: body.query,
- topK: body.topK
- });
- res.json({ results });
- } catch (err) {
- next(err);
- }
- });
|