langchain_community.docstore.arbitrary_fn.DocstoreFn¶

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

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)

delete(ids)

Deleting IDs from in memory dictionary.

search(search)

Search for a document.

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¶

Deleting IDs from in memory dictionary.

Parameters

ids (List) –

Return type

None

search(search: str) Document[source]¶

Search for a document.

Parameters

search (str) – search string

Returns

Document if found, else error message.

Return type

Document