iteration-fanout-reduce-seed-mutation.ts 549 B

1234567891011
  1. // reduce with an OBJECT accumulator mutated in place: at runtime the accumulator IS
  2. // the seed object (passed as the initial value), so acc.items.push(item) fills
  3. // seed.items with the glob results. The later ask over seed.items must see them.
  4. // Expected: source -> world-read#1; world-read#1 -> ask#1 (MUST); ask#1 -> sink.
  5. const items = await files.glob("*.md");
  6. const seed = { items: [] as string[] };
  7. items.reduce((acc, item) => {
  8. acc.items.push(item);
  9. return acc;
  10. }, seed);
  11. return agent("summarizer").ask<string>(seed.items.join(","));