collectionService.js 481 B

1234567891011121314151617
  1. import { config } from "../config/index.js";
  2. import { qdrant } from "./qdrantClient.js";
  3. export async function ensureCollection({ vectorSize }) {
  4. const collectionName = config.qdrant.collection;
  5. const existing = await qdrant.getCollections();
  6. const has = (existing?.collections ?? []).some((c) => c.name === collectionName);
  7. if (has) return;
  8. await qdrant.createCollection(collectionName, {
  9. vectors: {
  10. size: vectorSize,
  11. distance: "Cosine"
  12. }
  13. });
  14. }