Ubik80 commited on
Commit
ed99a77
·
verified ·
1 Parent(s): a7d9c36

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -0
app.py CHANGED
@@ -43,6 +43,8 @@ final_answer = FinalAnswerTool()
43
 
44
  from smolagents import tool, DuckDuckGoSearchTool
45
 
 
 
46
  @tool
47
  def search_duckduckgo(query: str, num_results: int = 3) -> str:
48
  """Performs a web search using DuckDuckGo and returns multiple relevant results.
@@ -72,6 +74,10 @@ def search_duckduckgo(query: str, num_results: int = 3) -> str:
72
  title = result_lines[i][1:title_end] # Extract title
73
  link = result_lines[i][title_end+2:].strip() # Extract link
74
 
 
 
 
 
75
  # Ensure the link is valid
76
  if not link.startswith("http"):
77
  continue # Skip invalid links
@@ -96,6 +102,7 @@ def search_duckduckgo(query: str, num_results: int = 3) -> str:
96
 
97
 
98
 
 
99
  model = OpenAIServerModel(
100
  max_tokens=2096,
101
  temperature=0.5,
 
43
 
44
  from smolagents import tool, DuckDuckGoSearchTool
45
 
46
+ from smolagents import tool, DuckDuckGoSearchTool
47
+
48
  @tool
49
  def search_duckduckgo(query: str, num_results: int = 3) -> str:
50
  """Performs a web search using DuckDuckGo and returns multiple relevant results.
 
74
  title = result_lines[i][1:title_end] # Extract title
75
  link = result_lines[i][title_end+2:].strip() # Extract link
76
 
77
+ # ✅ FIX: Rimuovere eventuali parentesi extra alla fine del link
78
+ if link.endswith(")"):
79
+ link = link[:-1] # Rimuoviamo l'ultima parentesi
80
+
81
  # Ensure the link is valid
82
  if not link.startswith("http"):
83
  continue # Skip invalid links
 
102
 
103
 
104
 
105
+
106
  model = OpenAIServerModel(
107
  max_tokens=2096,
108
  temperature=0.5,