langdash.search package#
Submodules#
langdash.search.embedding_search module#
Classes:
|
A search engine that uses vector embeddings from a language model. |
- class langdash.search.embedding_search.EmbeddingSearch(embd_session: LLMEmbeddingSession, embd_formatter: str = '{text}')[source]#
Bases:
EngineA search engine that uses vector embeddings from a language model.
- Parameters:
embd_session (LLMEmbeddingSession) – An LLMSession object for models that supports embeddings.
embd_formatter (str) –
Formatting string which will be used to preprocess raw text before passing into the model. This string must contain the text variable as formatting argument.
Defaults to “{text}”.
Methods:
add(text_raw)Add one or more documents to the search engine.
search(text[, max_documents])Search for documents relating to text in the engine.
- add(text_raw: str | List[str])[source]#
Add one or more documents to the search engine.
- Arg:
- texts (Union[str, List[str]]):
a document or a list of documents to add to the search engine.
- search(text: str, max_documents: int = 1) Generator[Tuple[int, str, float], None, None][source]#
Search for documents relating to text in the engine.
- Parameters:
text (str) – The text to search for in the documents.
max_documents (int) – The maximum number of documents to search through. Default is 1.
- Returns:
A generator of tuples containing the index of the document, its content and its relevance score to the search text.
langdash.search.engine module#
Classes:
|
Base class representing a search engine that can search for texts in a collection of documents. |
- class langdash.search.engine.Engine[source]#
Bases:
objectBase class representing a search engine that can search for texts in a collection of documents.
Methods:
add(texts)Add one or more documents to the search engine.
search(text[, max_documents])Search for documents relating to text in the engine.
- add(texts: str | List[str])[source]#
Add one or more documents to the search engine.
- Arg:
- texts (Union[str, List[str]]):
a document or a list of documents to add to the search engine.
- search(text: str, max_documents: int = 1) Generator[Tuple[int, str, float], None, None][source]#
Search for documents relating to text in the engine.
- Parameters:
text (str) – The text to search for in the documents.
max_documents (int) – The maximum number of documents to search through. Default is 1.
- Returns:
A generator of tuples containing the index of the document, its content and its relevance score to the search text.
langdash.search.multichoice_search module#
Classes:
|
A search engine that uses multiple choice questions to ask the most relevant documents from a generative language model. |
- class langdash.search.multichoice_search.MultichoiceSearch(prompt_chain: ~langdash.chains.chains.LDChainCached, document_prompt: ~typing.Callable[[~langdash.search.multichoice_search.MultichoiceSearch, int, str], ~typing.Tuple[str, str]] = <function number_based_prompt>)[source]#
Bases:
EngineA search engine that uses multiple choice questions to ask the most relevant documents from a generative language model.
Methods:
add(texts)Add one or more documents to the search engine.
search(text[, max_documents])Search for documents relating to text in the engine.
- add(texts: str | List[str])[source]#
Add one or more documents to the search engine.
- Arg:
- texts (Union[str, List[str]]):
a document or a list of documents to add to the search engine.
- search(text: str, max_documents: int = 1) Generator[Tuple[int, str, float], None, None][source]#
Search for documents relating to text in the engine.
- Parameters:
text (str) – The text to search for in the documents.
max_documents (int) – The maximum number of documents to search through. Default is 1.
- Returns:
A generator of tuples containing the index of the document, its content and its relevance score to the search text.