langchain.docstore.arbitrary_fn.DocstoreFn¶

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

Bases: Docstore

Langchain Docstore via arbitrary lookup function.

This is useful when:
  • it’s expensive to construct an InMemoryDocstore/dict

  • you retrieve documents from remote sources

  • you just want to reuse existing objects

Methods

__init__(lookup_fn)

search(search)

Search for a document.

search(search: str) Document[source]¶

Search for a document.

Parameters

search – search string

Returns

Document if found, else error message.