DataStax Astra DBApache Cassandra® 기반으로 구축된 서버리스 AI 지원 데이터베이스로, 사용하기 쉬운 JSON API를 통해 편리하게 사용할 수 있습니다.

Overview

Astra DB Document Loader는 Astra DB collection에서 읽은 LangChain Document 객체 목록을 반환합니다. loader는 다음 매개변수를 사용합니다:
  • api_endpoint: Astra DB API endpoint. https://01234567-89ab-cdef-0123-456789abcdef-us-east1.apps.astra.datastax.com와 같은 형식입니다
  • token: Astra DB token. AstraCS:aBcD0123...와 같은 형식입니다
  • collection_name : AstraDB collection 이름
  • namespace: (선택사항) AstraDB namespace (Astra DB에서는 _keyspace_라고 함)
  • filter_criteria: (선택사항) find query에 사용되는 필터
  • projection: (선택사항) find query에 사용되는 projection
  • limit: (선택사항) 검색할 최대 document 수
  • extraction_function: (선택사항) AstraDB document를 LangChain page_content 문자열로 변환하는 함수. 기본값은 json.dumps입니다
loader는 읽은 document에 대해 다음 metadata를 설정합니다:
metadata={
    "namespace": "...",
    "api_endpoint": "...",
    "collection": "..."
}

Setup

!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