langchain_community.document_loaders.git
.GitLoader¶
- class langchain_community.document_loaders.git.GitLoader(repo_path: str, clone_url: Optional[str] = None, branch: Optional[str] = 'main', file_filter: Optional[Callable[[str], bool]] = None)[source]¶
加载`Git`存储库文件。
存储库可以是本地磁盘上的,位于`repo_path`处, 也可以是远程的,位于将被克隆到`repo_path`的`clone_url`。 目前,仅支持文本文件。
每个文档代表存储库中的一个文件。`path`指向 本地Git存储库,`branch`指定要加载文件的分支。 默认情况下,它从`main`分支加载。
参数: repo_path:Git存储库的路径。 clone_url:可选。克隆存储库的URL。 branch:可选。要加载文件的分支。默认为“main”。 file_filter:可选。接受文件路径并返回一个布尔值,指示是否加载文件的函数。默认为None。
Methods
__init__
(repo_path[, clone_url, branch, ...])参数: repo_path:Git存储库的路径。 clone_url:可选。克隆存储库的URL。 branch:可选。要加载文件的分支。默认为“main”。 file_filter:可选。接受文件路径并返回一个布尔值,指示是否加载文件的函数。默认为None。
一个用于文档的惰性加载器。
aload
()将数据加载到文档对象中。
一个用于文档的惰性加载器。
load
()将数据加载到文档对象中。
load_and_split
([text_splitter])加载文档并分割成块。块作为文档返回。
- Parameters
repo_path (str) –
clone_url (Optional[str]) –
branch (Optional[str]) –
file_filter (Optional[Callable[[str], bool]]) –
- __init__(repo_path: str, clone_url: Optional[str] = None, branch: Optional[str] = 'main', file_filter: Optional[Callable[[str], bool]] = None)[source]¶
参数: repo_path:Git存储库的路径。 clone_url:可选。克隆存储库的URL。 branch:可选。要加载文件的分支。默认为“main”。 file_filter:可选。接受文件路径并返回一个布尔值,指示是否加载文件的函数。默认为None。
- Parameters
repo_path (str) –
clone_url (Optional[str]) –
branch (Optional[str]) –
file_filter (Optional[Callable[[str], bool]]) –
- load_and_split(text_splitter: Optional[TextSplitter] = None) List[Document] ¶
加载文档并分割成块。块作为文档返回。
不要覆盖此方法。应该被视为已弃用!
- 参数:
- text_splitter: 用于分割文档的TextSplitter实例。
默认为RecursiveCharacterTextSplitter。
- 返回:
文档列表。
- Parameters
text_splitter (Optional[TextSplitter]) –
- Return type
List[Document]