Shreyas094 commited on
Commit
10707fd
·
verified ·
1 Parent(s): f0e3a92

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -34,14 +34,18 @@ def get_web_search_results(query: str, max_results: int = 10) -> List[Dict[str,
34
  def rephrase_query(original_query: str, conversation_manager: ConversationManager) -> str:
35
  context = conversation_manager.get_context()
36
  if context:
37
- prompt = f"""You are a highly intelligent conversational chatbot. You have been given the following context and a new query, rephrase the query to make it more specific and contextual. Provide ONLY the rephrased query without any additional explanation:
38
 
 
 
 
 
 
39
  Context: {context}
40
-
41
  New query: {original_query}
42
-
43
  Rephrased query:"""
44
-
45
  response = DDGS().chat(prompt, model="llama-3.1-70b")
46
  # Extract only the rephrased query, removing any explanations
47
  rephrased_query = response.split('\n')[0].strip()
 
34
  def rephrase_query(original_query: str, conversation_manager: ConversationManager) -> str:
35
  context = conversation_manager.get_context()
36
  if context:
37
+ prompt = f"""You are a highly intelligent conversational chatbot. Your task is to analyze the given context and new query, then decide whether to rephrase the query with or without incorporating the context. Follow these steps:
38
 
39
+ 1. Determine if the new query is a continuation of the previous conversation or an entirely new topic.
40
+ 2. If it's a continuation, rephrase the query by incorporating relevant information from the context to make it more specific and contextual.
41
+ 3. If it's a new topic, rephrase the query to make it more appropriate for a web search, focusing on clarity and accuracy without using the previous context.
42
+ 4. Provide ONLY the rephrased query without any additional explanation or reasoning.
43
+
44
  Context: {context}
45
+
46
  New query: {original_query}
47
+
48
  Rephrased query:"""
 
49
  response = DDGS().chat(prompt, model="llama-3.1-70b")
50
  # Extract only the rephrased query, removing any explanations
51
  rephrased_query = response.split('\n')[0].strip()