langchain_community.docstore.arbitrary_fn.DocstoreFn

class langchain_community.docstore.arbitrary_fn.DocstoreFn(lookup_fn: Callable[[str], Union[Document, str]])[source]

通过任意查找函数进行文档存储。

当以下情况时,这将非常有用:
  • 构建InMemoryDocstore/dict的成本很高

  • 从远程源检索文档

  • 想要重用现有对象

Methods

__init__(lookup_fn)

delete(ids)

从内存中的字典中删除ID。

search(search)

搜索文档。

Parameters

lookup_fn (Callable[[str], Union[Document, str]]) –

__init__(lookup_fn: Callable[[str], Union[Document, str]])[source]
Parameters

lookup_fn (Callable[[str], Union[Document, str]]) –

delete(ids: List) None

从内存中的字典中删除ID。

Parameters

ids (List) –

Return type

None

search(search: str) Document[source]

搜索文档。

参数:

search: 搜索字符串

返回:

如果找到文档,则返回文档,否则返回错误消息。

Parameters

search (str) –

Return type

Document