components.result
This module provides the LettuceResult class, which is designed to hold and manage data flowing through different stages of the lettuce pipeline.
LettuceResult
class LettuceResult(
search_term: str
)A class to hold the results of different stages of lettuce pipelines.
Parameters
Methods
-
search_term: strThe search or source term serving as input for the pipeline (e.g., informal drug name)
add_vector_search_results
def add_vector_search_results(
vector_search_results:
)Stores vector search results from embedding-based similarity search part of the RAG pipeline.
Parameters
-
vector_search_results: List[Dict[str, Any]]List of dictionaries containing vector search results, typically with similarity scores and matched concepts
add_llm_answer
def add_llm_answer(
llm_answer: str
)Insert the results of an LLM assistant’s inference.
Parameters
-
llm_answer: strThe reply of an LLM
get_query
def get_query()Retrieve the appropriate part of the result object for querying an OMOP-CDM database.
If no previous stages have been executed, uses the search_term.
If there’s only a vector search result, uses the top result.
If there is a response from an LLM, uses that.
Returns
-
strTerm for a database query
add_matches
def add_matches(
omop_matches: list,
threshold: float
)Inserts the matches retrieved from a database search, after fuzzy string filtering.
Parameters
-
omop_matches: listA list of the matches retrieved from the database
-
threshold: floatThe threshold used for filtering
to_dict
def to_dict()Serialises the result as a dictionary
Returns
-
dictPipeline results serialised