{"id":14854,"library":"ragstack-ai-knowledge-store","title":"RAGStack AI Knowledge Store","description":"ragstack-ai-knowledge-store is a component of the DataStax RAGStack AI ecosystem, focusing on graph-based knowledge storage and retrieval. It allows users to build and query knowledge graphs backed by Astra DB, DataStax's cloud-native database. The current version is 0.2.1. While the main `ragstack-ai` project has frequent releases, this sub-package's versioning may not always align directly with the primary project's major versions.","status":"active","version":"0.2.1","language":"en","source_language":"en","source_url":"https://github.com/datastax/ragstack-ai","tags":["RAG","knowledge graph","graph database","DataStax","AstraDB","LLM","LangChain"],"install":[{"cmd":"pip install ragstack-ai-knowledge-store","lang":"bash","label":"Install core package"}],"dependencies":[{"reason":"Required for core functionalities and document handling, provides base interfaces.","package":"ragstack-ai-datastax-langchain-core","optional":false},{"reason":"Used for data validation and settings management within the library.","package":"pydantic","optional":false},{"reason":"The umbrella RAGStack library, often implicitly or explicitly required for a full RAGStack setup.","package":"ragstack-ai","optional":true}],"imports":[{"note":"This is the primary class for interacting with a graph knowledge store in Astra DB.","symbol":"AstraDBKnowledgeStore","correct":"from ragstack_ai.knowledge_store import AstraDBKnowledgeStore"}],"quickstart":{"code":"import os\nfrom ragstack_ai.knowledge_store import AstraDBKnowledgeStore\nfrom langchain_core.documents import Document\n\n# Ensure Astra DB credentials are set as environment variables\n# ASTRA_DB_APPLICATION_TOKEN, ASTRA_DB_ID, ASTRA_DB_KEYSPACE (optional, defaults to 'default')\n\nastra_db_token = os.environ.get(\"ASTRA_DB_APPLICATION_TOKEN\", \"YOUR_ASTRA_DB_TOKEN\")\nastra_db_id = os.environ.get(\"ASTRA_DB_ID\", \"YOUR_ASTRA_DB_ID\")\nastra_db_keyspace = os.environ.get(\"ASTRA_DB_KEYSPACE\", \"default\")\n\nif not all([astra_db_token, astra_db_id]):\n    print(\"Please set ASTRA_DB_APPLICATION_TOKEN and ASTRA_DB_ID environment variables.\")\n    exit()\n\ntry:\n    # Initialize the Knowledge Store\n    kg_store = AstraDBKnowledgeStore(\n        astra_db_id=astra_db_id,\n        astra_db_application_token=astra_db_token,\n        astra_db_keyspace=astra_db_keyspace,\n        graph_name=\"my_rag_knowledge_graph\" # A unique name for your graph\n    )\n\n    # Add documents to the knowledge store\n    documents = [\n        Document(page_content=\"Leonardo da Vinci was an Italian polymath.\", metadata={\"source\": \"wiki\"}),\n        Document(page_content=\"The Mona Lisa is a half-length portrait painting by Leonardo da Vinci.\", metadata={\"source\": \"wiki\"})\n    ]\n\n    print(\"Adding documents...\")\n    kg_store.add_documents(documents=documents)\n    print(\"Documents added successfully.\")\n\n    # Example: Simple graph traversal (conceptual, actual queries depend on graph structure)\n    # Note: Complex graph queries typically use specific methods or a dedicated graph query engine.\n    # This demonstrates basic interaction.\n    print(f\"Knowledge Store initialized for graph: {kg_store.graph_name}\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n    print(\"Ensure your Astra DB credentials are correct and the database is accessible.\")\n","lang":"python","description":"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."},"warnings":[{"fix":"Always check the specific PyPI page for `ragstack-ai-knowledge-store` for its correct version and dependencies. Do not assume it is locked to the main `ragstack-ai` project's version.","message":"The PyPI version of `ragstack-ai-knowledge-store` (e.g., 0.2.1) might be significantly lower than the overall `ragstack-ai` project's GitHub release versions (e.g., 1.x.x). This can lead to confusion or dependency conflicts if not managed carefully.","severity":"gotcha","affected_versions":"<1.0.0"},{"fix":"Ensure you have an Astra DB account, a database provisioned, and generate an Application Token. Set `ASTRA_DB_APPLICATION_TOKEN` and `ASTRA_DB_ID` as environment variables or pass them directly to the `AstraDBKnowledgeStore` constructor.","message":"This library is tightly coupled with DataStax Astra DB. It does not provide a local or in-memory graph store option. An active Astra DB instance and valid application token/database ID are mandatory for operation.","severity":"breaking","affected_versions":"All versions"},{"fix":"Familiarize yourself with graph database concepts and the specific methods provided by `AstraDBKnowledgeStore` for adding and retrieving graph-structured data. For full LangChain/LlamaIndex integration, consult the documentation for `ragstack-ai-langchain` or `ragstack-ai-llamaindex`.","message":"While part of the RAGStack ecosystem, `ragstack-ai-knowledge-store` specifically deals with graph data. Its query interface and interaction patterns are different from generic vector stores. Integrating it directly into LangChain or LlamaIndex RAG chains might require specific RAGStack connectors (e.g., `ragstack-ai-langchain`).","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Run `pip install ragstack-ai-knowledge-store` to install the package. Double-check the import statement: `from ragstack_ai.knowledge_store import AstraDBKnowledgeStore`.","cause":"The `ragstack-ai-knowledge-store` package is not installed or there's a typo in the import path.","error":"ModuleNotFoundError: No module named 'ragstack_ai.knowledge_store'"},{"fix":"Verify 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.","cause":"The provided `ASTRA_DB_ID` or `ASTRA_DB_APPLICATION_TOKEN` is incorrect or the database does not exist/is not accessible.","error":"astrapy.exceptions.DevOpsAPIException: No database with ID '...' found"},{"fix":"Always 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(...)])`.","cause":"The `add_documents` method expects an iterable (e.g., a list) of `Document` objects, but it received a single `Document` or an incorrect type.","error":"TypeError: add_documents() missing 1 required positional argument: 'documents'"}],"ecosystem":"pypi"}