TierraX commited on
Commit
10c8fc8
·
verified ·
1 Parent(s): b8316fe

Update app.py

Browse files

Refactoring and simplifying of the web_search tool to get rid of errors caused by unnecessary formatting

Files changed (1) hide show
  1. app.py +6 -8
app.py CHANGED
@@ -22,14 +22,12 @@ def web_search(query: str) -> str: #it's import to specify the return type
22
  # Perform the search
23
  results = search_tool(query)
24
 
25
- # Format the results
26
- formatted_results = []
27
- for i, result in enumerate(result, 1):
28
- formatted_results.append(f"{i}. Title: {result.title}")
29
- formatted_results.append(f" Link: {result.link}")
30
- formatted_results.append(f" Snippet: {result.snippet}\n")
31
-
32
- return "\n".join(formatted_results) if formatted_results else "No results found."
33
 
34
  except Exception as e:
35
  return f"Error performing search: {str(e)}"
 
22
  # Perform the search
23
  results = search_tool(query)
24
 
25
+ # Print results for debugging
26
+ if not results:
27
+ return "No results found."
28
+
29
+ # Format results as a simple string
30
+ return str(results)
 
 
31
 
32
  except Exception as e:
33
  return f"Error performing search: {str(e)}"