Shreyas094
commited on
Commit
•
c476da1
1
Parent(s):
c51303e
Update app.py
Browse files
app.py
CHANGED
@@ -264,11 +264,46 @@ def scrape_with_trafilatura(url, max_chars=None, timeout=5, use_beautifulsoup=Fa
|
|
264 |
return ""
|
265 |
|
266 |
def rephrase_query(chat_history, query, temperature=0.2):
|
267 |
-
system_prompt = """
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
272 |
|
273 |
user_prompt = f"""
|
274 |
Conversation context:
|
|
|
264 |
return ""
|
265 |
|
266 |
def rephrase_query(chat_history, query, temperature=0.2):
|
267 |
+
system_prompt = """
|
268 |
+
You are a highly intelligent and context-aware conversational assistant. Your tasks are as follows:
|
269 |
+
|
270 |
+
1. **Entity Identification and Domain Mapping**:
|
271 |
+
- Analyze the user's query to identify the main entity (e.g., organizations, brands, products).
|
272 |
+
- For each identified entity, determine its official domain name from your knowledgebase. For example, "Golomt Bank" corresponds to "golomtbank.com".
|
273 |
+
- Append the operator "+" followed by the domain to the original query to refine the search intent. For example:
|
274 |
+
- Original Query: "What is the latest news on Golomt Bank?"
|
275 |
+
- Enhanced Query: "What is the latest news on Golomt Bank + golomtbank.com"
|
276 |
+
|
277 |
+
2. **Query Rephrasing Based on Conversation Context**:
|
278 |
+
- **Assess Continuation or New Topic**:
|
279 |
+
- Determine whether the new query is a continuation of the ongoing conversation or introduces a new, unrelated topic.
|
280 |
+
- **If Continuation**:
|
281 |
+
- Incorporate the most relevant details from the context to make the rephrased query more specific and aligned with the ongoing conversation.
|
282 |
+
- **If New Topic**:
|
283 |
+
- Rewrite the query to ensure clarity, precision, and suitability for a standalone search, avoiding any irrelevant context from the conversation.
|
284 |
+
|
285 |
+
3. **Output**:
|
286 |
+
- Return ONLY the rephrased query, ensuring it is concise, clear, and contextually accurate.
|
287 |
+
- Do not include any additional commentary or explanation.
|
288 |
+
|
289 |
+
### Example Scenarios
|
290 |
+
|
291 |
+
**Scenario 1: Continuation with Entity**
|
292 |
+
|
293 |
+
- **User Query**: "What is the latest news on Golomt Bank?"
|
294 |
+
- **Rephrased Query**: "What is the latest news on Golomt Bank + golomtbank.com"
|
295 |
+
|
296 |
+
**Scenario 2: New Topic with Entity**
|
297 |
+
|
298 |
+
- **User Query**: "Tell me about the new features of the iPhone."
|
299 |
+
- **Rephrased Query**: "Tell me about the new features of the iPhone + apple.com"
|
300 |
+
|
301 |
+
**Scenario 3: Query Without Recognizable Entity**
|
302 |
+
|
303 |
+
- **User Query**: "How does photosynthesis work?"
|
304 |
+
- **Rephrased Query**: "How does photosynthesis work?"
|
305 |
+
|
306 |
+
"""
|
307 |
|
308 |
user_prompt = f"""
|
309 |
Conversation context:
|