txtLoader.js 272 B

123456789101112
  1. export async function loadTxtFromString(text, { source, metadata } = {}) {
  2. const normalized = String(text ?? "").trim();
  3. if (!normalized) return [];
  4. return [
  5. {
  6. text: normalized,
  7. source: source ?? "txt",
  8. metadata: metadata ?? null
  9. }
  10. ];
  11. }