Construct a MongoDB KnowLedge Graph for RAG
from a MongoDB connection URI.
from_connection_string(
cls,
connection_string: str,
database_name: str,
collection_name: str,
entity_extraction_model: BaseChatModel,
entity_prompt: ChatPromptTemplate = prompts.entity_prompt,
query_prompt: ChatPromptTemplate = prompts.query_prompt,
max_depth: int = 3,
allowed_entity_types: Optional[List[str]] = None,
allowed_relationship_types: Optional[List[str]] = None,
entity_examples: Optional[str] = None,
entity_name_examples: str = '',
validate: bool = False,
validation_action: str = 'warn'
) -> MongoDBGraphStore| Name | Type | Description |
|---|---|---|
connection_string* | str | A valid MongoDB connection URI. |
database_name* | str | The name of the database to connect to. |
collection_name* | str | The name of the collection to connect to. |
entity_extraction_model* | BaseChatModel | LLM for converting documents into Graph of Entities and Relationships. |
entity_prompt | ChatPromptTemplate | Default: prompts.entity_promptPrompt to fill graph store with entities following schema. |
query_prompt | ChatPromptTemplate | Default: prompts.query_promptPrompt extracts entities and relationships as search starting points. |
max_depth | int | Default: 3Maximum recursion depth in graph traversal. |
allowed_entity_types | Optional[List[str]] | Default: NoneIf provided, constrains search to these types. |
allowed_relationship_types | Optional[List[str]] | Default: NoneIf provided, constrains search to these types. |
entity_examples | Optional[str] | Default: NoneA string containing any number of additional examples to provide as context for entity extraction. |
entity_name_examples | str | Default: ''A string appended to prompts.NAME_EXTRACTION_INSTRUCTIONS containing examples. |
validate | bool | Default: FalseIf True, entity schema will be validated on every insert or update. |
validation_action | str | Default: 'warn'One of {"warn", "error"}.
|