misba-code commited on
Commit
c7059d8
·
verified ·
1 Parent(s): 6b04ecb

Format the results with clear DuckDuckGo attribution

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -26,6 +26,11 @@ def search_tool(query:str, num_results:int = 3)-> str: #it's import to specify t
26
 
27
  #format the results
28
  formatted_results = []
 
 
 
 
 
29
  for i, result in enumerate(results,1):
30
  formatted_results.append(
31
  f"{i}. Title: {result['title']}\n"
@@ -34,9 +39,9 @@ def search_tool(query:str, num_results:int = 3)-> str: #it's import to specify t
34
  )
35
 
36
  #combine results into a single string
37
- if formatted_results:
38
  return "search Results:\n\n" + "\n".join(formatted_results)
39
- else:
40
  return "no results found for the given query."
41
 
42
  except Exception as e:
 
26
 
27
  #format the results
28
  formatted_results = []
29
+
30
+ output = f"🔍 DuckDuckGo Search Results for query: '{query}'\n"
31
+ output += f"Number of results requested: {num_results}\n"
32
+ output += "----------------------------------------\n\n"
33
+
34
  for i, result in enumerate(results,1):
35
  formatted_results.append(
36
  f"{i}. Title: {result['title']}\n"
 
39
  )
40
 
41
  #combine results into a single string
42
+ if formatted_results:
43
  return "search Results:\n\n" + "\n".join(formatted_results)
44
+ else:
45
  return "no results found for the given query."
46
 
47
  except Exception as e: