Coverage for src/lilbee/retrieval/query/expansion.py: 100%

7 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-08-14 11:46 +0000

1"""Constants for LLM-driven query expansion, HyDE, and history condensation.""" 

2 

3from __future__ import annotations 

4 

5EXPANSION_PROMPT = ( 

6 "Generate {count} alternative search queries for the following question. " 

7 "Return ONLY the queries, one per line, no numbering or explanation.\n\n" 

8 "Question: {question}" 

9) 

10 

11EXPANSION_MAX_TOKENS = 200 

12 

13# HyDE writes one hypothetical answer passage to embed, which is a different 

14# shape of output from a list of query variants. Same number today, but tuning 

15# either one must not move the other. 

16HYDE_MAX_TOKENS = 200 

17 

18CONDENSE_PROMPT = ( 

19 "Rewrite the follow-up question as one standalone search query, resolving " 

20 "pronouns and references using the conversation. Return ONLY the rewritten " 

21 "query, nothing else. If the question already stands alone, return it " 

22 "unchanged.\n\nConversation:\n{history}\n\nFollow-up question: {question}" 

23) 

24 

25CONDENSE_MAX_TOKENS = 120 

26 

27# Trailing history messages included in the condensation prompt (one 

28# ChatMessage each, so 6 is the last 3 user/assistant exchanges); older 

29# messages rarely change what a follow-up refers to and only add latency. 

30CONDENSE_HISTORY_TURNS = 6