S
STONI
AI
Strands
Example
Notion
Series

Strands SDK 시리즈 5: 실전 — 뉴스 요약·태깅 파이프라인

아래는 한 파일에 모은 예시지만, 실제 프로젝트에서는 도구/스트랜드/구성을 분리하는 것을 권장합니다.

import { strand, tool, run } from strands;

const fetchRss = tool({
  name: fetchRss,
  run: async (url: string) => (await fetch(url)).text()
});

const summarize = tool({
  name: summarize,
  run: async (html: string) => {
    // LLM 호출 위치 — 예시로 의사코드
    return await llm.summarize(extractText(html), { style: bullet });
  }
});

const tagger = tool({
  name: tagger,
  run: async (text: string) => await llm.keywords(text, { topK: 5 })
});

const toNotion = tool({
  name: toNotion,
  run: async (page: { title: string; summary: string; tags: string[] }) => {
    // Notion API 적재 — 예시
    return await fetch(https://api.notion.com/pages, { method: POST, body: JSON.stringify(page) });
  }
});

export const pipeline = strand({
  name: news-pipeline,
  steps: [
    async (ctx) => {
      const rss = await ctx.run(fetchRss, https://hnrss.org/frontpage);
      ctx.state.html = rss;
      return summarize;
    },
    async (ctx) => {
      ctx.state.summary = await ctx.run(summarize, ctx.state.html);
      return tag;
    },
    async (ctx) => {
      ctx.state.tags = await ctx.run(tagger, ctx.state.summary);
      return store;
    },
    async (ctx) => {
      await ctx.run(toNotion, { title: HN
Clickable cat