8PeopleINC commited on
Commit
ffa76fb
·
verified ·
1 Parent(s): 8a2cec7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -8
app.py CHANGED
@@ -20,15 +20,23 @@ def ddg_tool(query:str, city:str, max_results:int=5)-> list: # it's important to
20
 
21
  Returns: List of dictionaries with Restaurant Name, city, and URL.
22
  """
 
 
 
 
 
 
 
 
 
23
  results = []
24
- with DuckDuckGoSearchTool as ddg_tool:
25
- for result in ddg_tool.text(query, max_results = max_results):
26
- results.append({
27
- "title": result["title"],
28
- "url": result["href"],
29
- "snippet":result["body"]
30
- })
31
-
32
  return results
33
 
34
 
 
20
 
21
  Returns: List of dictionaries with Restaurant Name, city, and URL.
22
  """
23
+ # Instantiate the tool
24
+ ddg = DuckDuckGoSearchTool()
25
+
26
+ # Modify query to include city for better results
27
+ full_query = f"{query} restaurant in {city}"
28
+
29
+ # Fetch results
30
+ search_results = ddg.search(full_query, max_results=max_results)
31
+
32
  results = []
33
+ for result in search_results:
34
+ results.append({
35
+ "title": result.get("title", "No Title"),
36
+ "url": result.get("href", "No URL"),
37
+ "snippet": result.get("body", "No Description")
38
+ })
39
+
 
40
  return results
41
 
42