Skip to main content
DataStax Astra DBApache Cassandra®를 기반으로 구축되고 사용하기 쉬운 JSON API를 통해 편리하게 사용할 수 있는 서버리스 AI 지원 데이터베이스입니다.

개요

Astra DB Document Loader는 Astra DB 컬렉션에서 읽은 LangChain Document 객체의 리스트를 반환합니다. 로더는 다음 매개변수를 사용합니다:
  • api_endpoint: Astra DB API 엔드포인트. https://01234567-89ab-cdef-0123-456789abcdef-us-east1.apps.astra.datastax.com과 같이 보입니다
  • token: Astra DB 토큰. AstraCS:aBcD0123...와 같이 보입니다
  • collection_name : AstraDB 컬렉션 이름
  • namespace: (선택 사항) AstraDB 네임스페이스(Astra DB에서는 _keyspace_라고 함)
  • filter_criteria: (선택 사항) find 쿼리에 사용되는 필터
  • projection: (선택 사항) find 쿼리에 사용되는 프로젝션
  • limit: (선택 사항) 검색할 최대 문서 수
  • extraction_function: (선택 사항) AstraDB 문서를 LangChain page_content 문자열로 변환하는 함수. 기본값은 json.dumps입니다
로더는 읽은 문서에 대해 다음 메타데이터를 설정합니다:
metadata={
    "namespace": "...",
    "api_endpoint": "...",
    "collection": "..."
}

설정

!pip install "langchain-astradb>=0.6,<0.7"

Document Loader로 문서 로드

from langchain_astradb import AstraDBLoader
API Reference: AstraDBLoader
from getpass import getpass

ASTRA_DB_API_ENDPOINT = input("ASTRA_DB_API_ENDPOINT = ")
ASTRA_DB_APPLICATION_TOKEN = getpass("ASTRA_DB_APPLICATION_TOKEN = ")
ASTRA_DB_API_ENDPOINT =  https://01234567-89ab-cdef-0123-456789abcdef-us-east1.apps.astra.datastax.com
ASTRA_DB_APPLICATION_TOKEN =  ········
loader = AstraDBLoader(
    api_endpoint=ASTRA_DB_API_ENDPOINT,
    token=ASTRA_DB_APPLICATION_TOKEN,
    collection_name="movie_reviews",
    projection={"title": 1, "reviewtext": 1},
    limit=10,
)
docs = loader.load()
docs[0]
Document(metadata={'namespace': 'default_keyspace', 'api_endpoint': 'https://01234567-89ab-cdef-0123-456789abcdef-us-east1.apps.astra.datastax.com', 'collection': 'movie_reviews'}, page_content='{"_id": "659bdffa16cbc4586b11a423", "title": "Dangerous Men", "reviewtext": "\\"Dangerous Men,\\" the picture\'s production notes inform, took 26 years to reach the big screen. After having seen it, I wonder: What was the rush?"}')

Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.
I