Recipes
RAG 지식 베이스
batch distill로 문서 사이트에서 벡터 스토어 구축하기
문서 사이트를 검색 가능한 RAG 지식 베이스로 변환하세요. URL을 배치로 제출하고, 완료될 때까지 폴링하거나 Webhook을 사용한 다음, 결과 Markdown을 벡터 스토어에 인덱싱합니다.
흐름
- 수집할 URL 발견 (sitemap, 크롤링, 또는 큐레이션된 목록)
- 단일
/batch/distill작업으로 제출 - 완료 대기 (폴링 또는 Webhook)
- 각 결과의
markdown을 벡터 스토어에 임베딩
구현
import httpx, time
API = "https://openapi.thunderbit.com/openapi/v1"
H = {"Authorization": "Bearer YOUR_API_KEY"}
urls = [f"https://docs.example.com/page-{i}" for i in range(50)]
job = httpx.post(f"{API}/batch/distill",
headers=H,
json={"urls": urls, "include": ["metadata"]}).json()
batch_id = job["data"]["id"]
while True:
status = httpx.get(f"{API}/batch/distill/{batch_id}", headers=H).json()["data"]
if status["status"] in ("COMPLETED", "FAILED", "CANCELLED"):
break
time.sleep(10)
for r in status["results"]:
if r["status"] == "SUCCEEDED":
embed_and_store(r["url"], r["markdown"])팁
include: ["metadata"]를 사용하면 각 결과에 청크 헤더용 title / description이 포함됩니다- 100개 이상의 URL의 경우, 폴링보다 Webhook을 권장합니다 — Webhooks 참고
- 동일한 URL을 다시 실행해도 무방합니다. 콘텐츠가 자주 바뀌면
forceRefresh: true로 캐시를 우회하세요
관련 문서
이 레시피는 벡터 스토어 연동 (Pinecone / Weaviate / pgvector) 으로 확장 중입니다 — 곧 업데이트됩니다.