Skip to content

OpenRAG is a comprehensive, single package Retrieval-Augmented Generation platform built on Langflow, Docling, and Opensearch.

Python
945 B
Raw Blame
import type { ParsedQueryData } from "@/contexts/knowledge-filter-context";
import { SEARCH_CONSTANTS } from "@/lib/constants";

/** Query data that loads all chunks for one filename (OpenSearch data_sources). */
export function fileScopedSearchQueryData(filename: string): ParsedQueryData {
  return {
    query: "*",
    filters: {
      data_sources: [filename],
      document_types: [],
      owners: [],
      connector_types: [],
    },
    limit: SEARCH_CONSTANTS.WILDCARD_QUERY_LIMIT,
    scoreThreshold: 0,
    color: "zinc",
    icon: "folder",
  };
}

/** Stable-document variant for URL child pages whose titles need not be unique. */
export function documentScopedSearchQueryData(
  documentId: string,
): ParsedQueryData {
  return {
    ...fileScopedSearchQueryData(""),
    filters: {
      data_sources: [],
      document_types: [],
      owners: [],
      connector_types: [],
      document_ids: [documentId],
    },
  };
}