akryldigital commited on
Commit
8e0fba6
Β·
verified Β·
1 Parent(s): 5840ff7

re-order prompt modules to increase cache hit rate

Browse files
src/agents/prompts/query_analysis.py CHANGED
@@ -48,13 +48,14 @@ DATABASE KNOWLEDGE (live from the vector store)
48
  ═══════════════════════════════════════
49
  UI FILTERS (set by user in the sidebar)
50
  ═══════════════════════════════════════
51
- {ui_filters if ui_filters else "None active β€” the user has not set any sidebar filters."}
52
  UI filters always take priority. If they are set, use them and do NOT override from the query text.
53
 
54
  ═══════════════════════════════════════
55
  PREVIOUS TURN FILTERS (from the last exchange in this conversation)
56
  ═══════════════════════════════════════
57
- {prev_filter_desc}
 
58
 
59
  ═══════════════════════════════════════
60
  CONVERSATION CONTINUITY RULES
@@ -311,13 +312,19 @@ OUTPUT FORMAT (JSON only, no other text)
311
  "needs_metadata_lookup": false
312
  }}"""
313
 
314
- user_content = f"""Query: {query}
 
 
 
 
 
 
 
 
315
 
316
  Conversation Context:
317
  {conversation_context}
318
 
319
- Previous turn filters: {prev_filter_desc}
320
-
321
  Analyze and return JSON:"""
322
 
323
  return ChatPromptTemplate.from_messages([
 
48
  ═══════════════════════════════════════
49
  UI FILTERS (set by user in the sidebar)
50
  ═══════════════════════════════════════
51
+ The current UI filter values are provided in the user message below under "UI FILTERS:".
52
  UI filters always take priority. If they are set, use them and do NOT override from the query text.
53
 
54
  ═══════════════════════════════════════
55
  PREVIOUS TURN FILTERS (from the last exchange in this conversation)
56
  ═══════════════════════════════════════
57
+ The previous-turn filter snapshot is provided in the user message below under "PREVIOUS TURN FILTERS:".
58
+ Use these for carry-forward / replace / expand decisions per the rules below.
59
 
60
  ═══════════════════════════════════════
61
  CONVERSATION CONTINUITY RULES
 
312
  "needs_metadata_lookup": false
313
  }}"""
314
 
315
+ _ui_filters_block = ui_filters if ui_filters else "None active β€” the user has not set any sidebar filters."
316
+
317
+ user_content = f"""UI FILTERS:
318
+ {_ui_filters_block}
319
+
320
+ PREVIOUS TURN FILTERS:
321
+ {prev_filter_desc}
322
+
323
+ Query: {query}
324
 
325
  Conversation Context:
326
  {conversation_context}
327
 
 
 
328
  Analyze and return JSON:"""
329
 
330
  return ChatPromptTemplate.from_messages([