core/apps/webapp/app/routes/api.v1.search.tsx
Harshith Mullapudi f39c7cc6d0
feat: remove trigger and run base on bullmq (#126)
* feat: remove trigger and run base on bullmq
* fix: telemetry and trigger deploymen
* feat: add Ollama container and update ingestion status for unchanged documents
* feat: add logger to bullmq workers
* 1. Remove chat and deep-search from trigger
2. Add ai/sdk for chat UI
3. Added a better model manager

* refactor: simplify clustered graph query and add stop conditions for AI responses

* fix: streaming

* fix: docker docs

---------

Co-authored-by: Manoj <saimanoj58@gmail.com>
2025-10-26 12:56:12 +05:30

64 lines
1.9 KiB
TypeScript

import { z } from "zod";
import {
createActionApiRoute,
createHybridActionApiRoute,
} from "~/services/routeBuilders/apiBuilder.server";
import { SearchService } from "~/services/search.server";
import { json } from "@remix-run/node";
import { trackFeatureUsage } from "~/services/telemetry.server";
export const SearchBodyRequest = z.object({
query: z.string(),
startTime: z.string().optional(),
endTime: z.string().optional(),
// These are not supported yet, but need to support these
spaceIds: z.array(z.string()).default([]),
limit: z.number().optional(),
maxBfsDepth: z.number().optional(),
includeInvalidated: z.boolean().optional(),
entityTypes: z.array(z.string()).optional(),
scoreThreshold: z.number().optional(),
minResults: z.number().optional(),
adaptiveFiltering: z.boolean().optional(),
structured: z.boolean().default(true),
});
const searchService = new SearchService();
const { action, loader } = createHybridActionApiRoute(
{
body: SearchBodyRequest,
allowJWT: true,
authorization: {
action: "search",
},
corsStrategy: "all",
},
async ({ body, authentication }) => {
const results = await searchService.search(
body.query,
authentication.userId,
{
startTime: body.startTime ? new Date(body.startTime) : undefined,
endTime: body.endTime ? new Date(body.endTime) : undefined,
limit: body.limit,
maxBfsDepth: body.maxBfsDepth,
includeInvalidated: body.includeInvalidated,
entityTypes: body.entityTypes,
scoreThreshold: body.scoreThreshold,
minResults: body.minResults,
spaceIds: body.spaceIds,
adaptiveFiltering: body.adaptiveFiltering,
structured: body.structured,
},
);
// Track search
trackFeatureUsage("search_performed", authentication.userId).catch(console.error);
return json(results);
},
);
export { action, loader };