Shreyas094 commited on
Commit
8339b76
·
verified ·
1 Parent(s): 8d354ca

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -272,7 +272,7 @@ def generate_chunked_response(prompt, model, max_tokens=10000, num_calls=3, temp
272
  return final_response
273
 
274
  class SimpleDDGSearch:
275
- def search(self, query: str, num_results: int = 5):
276
  results = DDGS().text(query, region='wt-wt', safesearch='off', max_results=num_results)
277
  return [res["href"] for res in results]
278
 
@@ -304,6 +304,7 @@ class CitingSources(BaseModel):
304
  ...,
305
  description="List of sources to cite. Should be an URL of the source."
306
  )
 
307
  def chatbot_interface(message, history, use_web_search, model, temperature, num_calls):
308
  if not message.strip():
309
  return "", history
@@ -500,7 +501,7 @@ def create_web_search_vectors(search_results):
500
 
501
  def get_response_with_search(query, model, num_calls=3, temperature=0.2):
502
  searcher = SimpleDDGSearch()
503
- search_results = searcher.search(query, num_results=5)
504
 
505
  crawler = TrafilaturaWebCrawler()
506
  context = ""
@@ -510,7 +511,7 @@ def get_response_with_search(query, model, num_calls=3, temperature=0.2):
510
 
511
  prompt = f"""Using the following context from web search results:
512
  {context}
513
- Write a detailed and complete research document that fulfills the following user request: '{query}'
514
  After writing the document, please provide a list of sources used in your response."""
515
 
516
  if model == "@cf/meta/llama-3.1-8b-instruct":
 
272
  return final_response
273
 
274
  class SimpleDDGSearch:
275
+ def search(self, query: str, num_results: int = 10):
276
  results = DDGS().text(query, region='wt-wt', safesearch='off', max_results=num_results)
277
  return [res["href"] for res in results]
278
 
 
304
  ...,
305
  description="List of sources to cite. Should be an URL of the source."
306
  )
307
+
308
  def chatbot_interface(message, history, use_web_search, model, temperature, num_calls):
309
  if not message.strip():
310
  return "", history
 
501
 
502
  def get_response_with_search(query, model, num_calls=3, temperature=0.2):
503
  searcher = SimpleDDGSearch()
504
+ search_results = searcher.search(query, num_results=10)
505
 
506
  crawler = TrafilaturaWebCrawler()
507
  context = ""
 
511
 
512
  prompt = f"""Using the following context from web search results:
513
  {context}
514
+ Write a detailed and complete research article that fulfills the following user request: '{query}'
515
  After writing the document, please provide a list of sources used in your response."""
516
 
517
  if model == "@cf/meta/llama-3.1-8b-instruct":