Shreyas094 commited on
Commit
7dd2856
·
verified ·
1 Parent(s): b7cb350

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -26
app.py CHANGED
@@ -224,32 +224,6 @@ def google_search(term, num_results=5, lang="en", timeout=5, safe="active", ssl_
224
 
225
  return all_results
226
 
227
- def rephrase_for_search(query, model):
228
- rephrase_prompt = PromptTemplate(
229
- input_variables=["query"],
230
- template="""
231
- Your task is to rephrase the given conversational query into a concise, search-engine-friendly format.
232
- Remove any conversational elements and focus on the core information need.
233
- Provide ONLY the rephrased query without any additional text or explanations.
234
-
235
- Conversational query: {query}
236
-
237
- Rephrased query:"""
238
- )
239
-
240
- chain = LLMChain(llm=model, prompt=rephrase_prompt)
241
- response = chain.run(query=query).strip()
242
-
243
- rephrased_query = response.replace("Rephrased query:", "").strip()
244
-
245
- if rephrased_query.lower() == query.lower() or len(rephrased_query) > len(query) * 1.5:
246
- common_words = set(['the', 'a', 'an', 'in', 'on', 'at', 'to', 'for', 'of', 'with', 'by', 'from', 'up', 'about', 'into', 'over', 'after'])
247
- keywords = [word.lower() for word in query.split() if word.lower() not in common_words]
248
- keywords = [word for word in keywords if word.isalnum()]
249
- return ' '.join(keywords)
250
-
251
- return rephrased_query
252
-
253
  def ask_question(question, temperature, top_p, repetition_penalty, web_search):
254
  if not question:
255
  return "Please enter a question."
 
224
 
225
  return all_results
226
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
227
  def ask_question(question, temperature, top_p, repetition_penalty, web_search):
228
  if not question:
229
  return "Please enter a question."