Spaces:
Runtime error
Runtime error
Download server/utils/ExpandQuery.py from WizardCoder2007/MANIT_Chat: direct link, hf CLI and curl.
- Browser
- Download file 1.09 kB
-
https://huggingface.co/spaces/WizardCoder2007/MANIT_Chat/resolve/main/server/utils/ExpandQuery.py
- Command line
-
hf download hf://spaces/WizardCoder2007/MANIT_Chat/server/utils/ExpandQuery.py
-
curl -L -o ExpandQuery.py https://huggingface.co/spaces/WizardCoder2007/MANIT_Chat/resolve/main/server/utils/ExpandQuery.py
1.09 kB
| from langchain_core.messages import HumanMessage, SystemMessage | |
| def expand_query(query,llm,factor=3): | |
| system_instruction= f""" | |
| You are an expert academic search optimization assistant for a college RAG database. | |
| Your job is to rewrite the user's input query into {factor} different, keyword-rich search variations. | |
| CRITICAL INSTRUCTIONS: | |
| 1. Maintain the exact semantic meaning but change casual or ambiguous phrasing into formal university terminology (e.g., convert 'faculties' to 'professors, lecturers, teaching staff', or 'syllabus' to 'curriculum scheme'). | |
| 2. Do NOT add any introductory text, pleasantries, or explanations. | |
| 3. Do NOT include numbers, bullet points, hyphens, or numbering prefixes (like '1.', '2.'). | |
| 4. Output ONLY the raw alternative queries, separating each distinct query with a single newline character (\n). | |
| """ | |
| messages= [SystemMessage(system_instruction),HumanMessage(query)] | |
| response= llm.invoke(messages) | |
| final_queries= response.content.split("\n\n") | |
| final_queries.append(query) | |
| return final_queries |