Martechsol commited on
Commit ·
8a2c74f
1
Parent(s): f117eae
Fix follow-up detection: add prepositional starters for context continuity
Browse files
app/services/rag_pipeline.py
CHANGED
|
@@ -203,7 +203,12 @@ def _expand_query_locally(message: str) -> List[str]:
|
|
| 203 |
# last user message from history. Used ONLY for retrieval — the LLM gets the
|
| 204 |
# original message + history for natural conversation flow.
|
| 205 |
_FOLLOWUP_PRONOUNS = {"them", "then", "it", "this", "that", "those", "these", "its"}
|
| 206 |
-
_FOLLOWUP_STARTERS = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 207 |
|
| 208 |
|
| 209 |
def _resolve_followup(message: str, history: List[Dict[str, str]]) -> str:
|
|
|
|
| 203 |
# last user message from history. Used ONLY for retrieval — the LLM gets the
|
| 204 |
# original message + history for natural conversation flow.
|
| 205 |
_FOLLOWUP_PRONOUNS = {"them", "then", "it", "this", "that", "those", "these", "its"}
|
| 206 |
+
_FOLLOWUP_STARTERS = {
|
| 207 |
+
"and ", "also ", "what about ", "how about ", "how to ",
|
| 208 |
+
# Prepositional modifiers — almost always continue the previous topic
|
| 209 |
+
# e.g. "during probation" after "leaves per annum" = "leaves during probation"
|
| 210 |
+
"during ", "after ", "before ", "for ", "without ", "on ", "in ", "if ",
|
| 211 |
+
}
|
| 212 |
|
| 213 |
|
| 214 |
def _resolve_followup(message: str, history: List[Dict[str, str]]) -> str:
|