Extract the actual question from formatted query.
(self, query: str)
| 333 | return final_answer, expanded_context, traversal_path, filtered_content |
| 334 | |
| 335 | def _extract_retrieval_query(self, query: str) -> str: |
| 336 | """Extract the actual question from formatted query.""" |
| 337 | import re |
| 338 | |
| 339 | patterns = [ |
| 340 | r"Now Answer the Question:\s*(.*)", |
| 341 | r"Here is the conversation:\s*(.*)", |
| 342 | ] |
| 343 | |
| 344 | for pattern in patterns: |
| 345 | match = re.search(pattern, query, re.DOTALL) |
| 346 | if match: |
| 347 | return ''.join(match.groups()) |
| 348 | |
| 349 | return query |
| 350 | |
| 351 | def _retrieve_relevant_documents(self, query: str) -> List: |
| 352 | """Retrieve relevant documents using compression retriever.""" |