Ubik80 commited on
Commit
bf7e7c8
·
verified ·
1 Parent(s): 46b9160

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -57,6 +57,8 @@ def search_duckduckgo(query: str, num_results: int = 3) -> str:
57
  search_tool = DuckDuckGoSearchTool()
58
  results = search_tool(query)
59
 
 
 
60
  if not results or "## Search Results" not in results:
61
  return f"No relevant results found for '{query}'."
62
 
@@ -68,20 +70,20 @@ def search_duckduckgo(query: str, num_results: int = 3) -> str:
68
  title = result_lines[i][1:-1] # Extract title
69
  link = result_lines[i+1].strip() # Extract link
70
 
71
- # Fix broken links and remove extra characters
72
- if not link.startswith("http"):
73
- continue # Skip invalid links
74
 
75
  summary = result_lines[i+2].strip() if i+2 < len(result_lines) else "No summary available."
76
 
77
- # Ensure the link format is clean
78
  formatted_result = f"🔎 **[{title}]({link})**\n📌 {summary}"
79
  parsed_results.append(formatted_result)
80
 
81
  if not parsed_results:
82
  return f"No valid results found for '{query}'."
83
 
84
- return "\n\n".join(parsed_results) # Return multiple results formatted nicely
 
85
 
86
 
87
 
 
57
  search_tool = DuckDuckGoSearchTool()
58
  results = search_tool(query)
59
 
60
+ print("DEBUG - Raw results from DuckDuckGo:\n", results) # 👀 Debugging
61
+
62
  if not results or "## Search Results" not in results:
63
  return f"No relevant results found for '{query}'."
64
 
 
70
  title = result_lines[i][1:-1] # Extract title
71
  link = result_lines[i+1].strip() # Extract link
72
 
73
+ # ⚠️ TEMPORANEAMENTE RIMOSSO IL FILTRO SUI LINK
74
+ # if not link.startswith("http"):
75
+ # continue # Skip invalid links
76
 
77
  summary = result_lines[i+2].strip() if i+2 < len(result_lines) else "No summary available."
78
 
 
79
  formatted_result = f"🔎 **[{title}]({link})**\n📌 {summary}"
80
  parsed_results.append(formatted_result)
81
 
82
  if not parsed_results:
83
  return f"No valid results found for '{query}'."
84
 
85
+ return "\n\n".join(parsed_results)
86
+
87
 
88
 
89