2023-12-11 21:53:30 +00:00
|
|
|
"""**Docstores** are classes to store and load Documents.
|
|
|
|
|
|
|
|
The **Docstore** is a simplified version of the Document Loader.
|
|
|
|
|
|
|
|
**Class hierarchy:**
|
|
|
|
|
|
|
|
.. code-block::
|
|
|
|
|
|
|
|
Docstore --> <name> # Examples: InMemoryDocstore, Wikipedia
|
|
|
|
|
|
|
|
**Main helpers:**
|
|
|
|
|
|
|
|
.. code-block::
|
|
|
|
|
|
|
|
Document, AddableMixin
|
|
|
|
"""
|
|
|
|
|
2024-03-11 20:37:36 +00:00
|
|
|
import importlib
|
2024-04-10 17:01:19 +00:00
|
|
|
from typing import TYPE_CHECKING, Any
|
|
|
|
|
|
|
|
if TYPE_CHECKING:
|
|
|
|
from langchain_community.docstore.arbitrary_fn import (
|
2024-04-30 17:13:48 +00:00
|
|
|
DocstoreFn,
|
2024-04-10 17:01:19 +00:00
|
|
|
)
|
|
|
|
from langchain_community.docstore.in_memory import (
|
2024-04-30 17:13:48 +00:00
|
|
|
InMemoryDocstore,
|
2024-04-10 17:01:19 +00:00
|
|
|
)
|
|
|
|
from langchain_community.docstore.wikipedia import (
|
2024-04-30 17:13:48 +00:00
|
|
|
Wikipedia,
|
2024-04-10 17:01:19 +00:00
|
|
|
)
|
|
|
|
|
2024-03-11 20:37:36 +00:00
|
|
|
_module_lookup = {
|
|
|
|
"DocstoreFn": "langchain_community.docstore.arbitrary_fn",
|
|
|
|
"InMemoryDocstore": "langchain_community.docstore.in_memory",
|
|
|
|
"Wikipedia": "langchain_community.docstore.wikipedia",
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
def __getattr__(name: str) -> Any:
|
|
|
|
if name in _module_lookup:
|
|
|
|
module = importlib.import_module(_module_lookup[name])
|
|
|
|
return getattr(module, name)
|
|
|
|
raise AttributeError(f"module {__name__} has no attribute {name}")
|
|
|
|
|
|
|
|
|
2024-05-22 17:42:17 +00:00
|
|
|
__all__ = ["DocstoreFn", "InMemoryDocstore", "Wikipedia"]
|