Skip to content

search_preprocessing_bot

django_spire.knowledge.intelligence.bots.search_preprocessing_bot

PreprocessedQueryIntel

Bases: BaseIntel

corrected_query instance-attribute

meaningful_words instance-attribute

expanded_terms instance-attribute

search_phrases instance-attribute

SearchPreprocessingBot

Bases: Bot

llm_intel_class = PreprocessedQueryIntel class-attribute instance-attribute

llm_role = 'Search Query Preprocessor' class-attribute instance-attribute

llm_task = 'Process a user search query to optimize it for knowledge base retrieval.' class-attribute instance-attribute

llm_guidelines = Prompt().list(['Correct any obvious spelling or grammar mistakes while preserving intent.', 'Identify meaningful words by removing stop words (the, a, an, is, are, how, what, can, do, etc.).', 'Keep technical terms, acronyms, nouns, verbs, and domain-specific vocabulary as meaningful words.', 'Generate 3-5 synonyms or related terms for key concepts in expanded_terms.', 'Provide 2-3 alternative search phrases in search_phrases.', 'Do not change proper nouns or technical terminology.']) class-attribute instance-attribute

process

Source code in django_spire/knowledge/intelligence/bots/search_preprocessing_bot.py
def process(self, query: str) -> PreprocessedQueryIntel:
    return self.llm.prompt_to_intel(
        prompt=f'Process this search query: {query}'
    )