document.cjs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.Document = void 0;
  4. /**
  5. * Interface for interacting with a document.
  6. */
  7. class Document {
  8. constructor(fields) {
  9. Object.defineProperty(this, "pageContent", {
  10. enumerable: true,
  11. configurable: true,
  12. writable: true,
  13. value: void 0
  14. });
  15. Object.defineProperty(this, "metadata", {
  16. enumerable: true,
  17. configurable: true,
  18. writable: true,
  19. value: void 0
  20. });
  21. // The ID field is optional at the moment.
  22. // It will likely become required in a future major release after
  23. // it has been adopted by enough vectorstore implementations.
  24. /**
  25. * An optional identifier for the document.
  26. *
  27. * Ideally this should be unique across the document collection and formatted
  28. * as a UUID, but this will not be enforced.
  29. */
  30. Object.defineProperty(this, "id", {
  31. enumerable: true,
  32. configurable: true,
  33. writable: true,
  34. value: void 0
  35. });
  36. this.pageContent =
  37. fields.pageContent !== undefined ? fields.pageContent.toString() : "";
  38. this.metadata = fields.metadata ?? {};
  39. this.id = fields.id;
  40. }
  41. }
  42. exports.Document = Document;