Registry /
llm-agents / ragstack-ai-knowledge-store
Install & Compatibility
Where this runs
tested against v0.2.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
py 3.10
✕ build_error
✓ 5.6s
py 3.11
✕ build_error
✓ 5.15s
py 3.12
✕ build_error
✓ 4.7s
py 3.13
✕ build_error
✓ 5.15s
126MB installed
● package 126MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
AstraDBKnowledgeStore
✓ from ragstack_ai.knowledge_store import AstraDBKnowledgeStore
This is the primary class for interacting with a graph knowledge store in Astra DB.
This quickstart demonstrates how to initialize `AstraDBKnowledgeStore` and add `langchain_core.documents.Document` objects to it. It requires an active Astra DB instance and valid credentials. The `graph_name` parameter identifies your specific knowledge graph within Astra DB.
import os
from ragstack_ai.knowledge_store import AstraDBKnowledgeStore
from langchain_core.documents import Document
# Ensure Astra DB credentials are set as environment variables
# ASTRA_DB_APPLICATION_TOKEN, ASTRA_DB_ID, ASTRA_DB_KEYSPACE (optional, defaults to 'default')
astra_db_token = os.environ.get("ASTRA_DB_APPLICATION_TOKEN", "YOUR_ASTRA_DB_TOKEN")
astra_db_id = os.environ.get("ASTRA_DB_ID", "YOUR_ASTRA_DB_ID")
astra_db_keyspace = os.environ.get("ASTRA_DB_KEYSPACE", "default")
if not all([astra_db_token, astra_db_id]):
print("Please set ASTRA_DB_APPLICATION_TOKEN and ASTRA_DB_ID environment variables.")
exit()
try:
# Initialize the Knowledge Store
kg_store = AstraDBKnowledgeStore(
astra_db_id=astra_db_id,
astra_db_application_token=astra_db_token,
astra_db_keyspace=astra_db_keyspace,
graph_name="my_rag_knowledge_graph" # A unique name for your graph
)
# Add documents to the knowledge store
documents = [
Document(page_content="Leonardo da Vinci was an Italian polymath.", metadata={"source": "wiki"}),
Document(page_content="The Mona Lisa is a half-length portrait painting by Leonardo da Vinci.", metadata={"source": "wiki"})
]
print("Adding documents...")
kg_store.add_documents(documents=documents)
print("Documents added successfully.")
# Example: Simple graph traversal (conceptual, actual queries depend on graph structure)
# Note: Complex graph queries typically use specific methods or a dedicated graph query engine.
# This demonstrates basic interaction.
print(f"Knowledge Store initialized for graph: {kg_store.graph_name}")
except Exception as e:
print(f"An error occurred: {e}")
print("Ensure your Astra DB credentials are correct and the database is accessible.")
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'ragstack_ai.knowledge_store'
The `ragstack-ai-knowledge-store` package is not installed or there's a typo in the import path.
fixRun `pip install ragstack-ai-knowledge-store` to install the package. Double-check the import statement: `from ragstack_ai.knowledge_store import AstraDBKnowledgeStore`.
astrapy.exceptions.DevOpsAPIException: No database with ID '...' found
The provided `ASTRA_DB_ID` or `ASTRA_DB_APPLICATION_TOKEN` is incorrect or the database does not exist/is not accessible.
fixVerify your Astra DB ID and Application Token. Ensure they are correctly set as environment variables or passed to the `AstraDBKnowledgeStore` constructor. Check your Astra DB dashboard for the correct ID and ensure the token has sufficient permissions.
TypeError: add_documents() missing 1 required positional argument: 'documents'
The `add_documents` method expects an iterable (e.g., a list) of `Document` objects, but it received a single `Document` or an incorrect type.
fixAlways pass a list of `Document` objects to `add_documents`, even if it's a list containing only one document: `kg_store.add_documents(documents=[Document(...)])`.
Upgrade
Version history
0.2.1latest on PyPI · released Jul 30, 2024
Audit
Dependencies
ragstack-ai-datastax-langchain-corerequiredRequired for core functionalities and document handling, provides base interfaces.
pydanticrequiredUsed for data validation and settings management within the library.
ragstack-aioptionalThe umbrella RAGStack library, often implicitly or explicitly required for a full RAGStack setup.