Spaces:
Runtime error
Runtime error
debug web_query 2
Browse files
app.py
CHANGED
|
@@ -16,8 +16,22 @@ def web_query(query:str)-> str: #it's import to specify the return type
|
|
| 16 |
query: User query to search the web
|
| 17 |
"""
|
| 18 |
print("RK test inside function")
|
| 19 |
-
query_result=DuckDuckGoSearchTool.forward(query)
|
| 20 |
-
return query_result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
@tool
|
| 23 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 16 |
query: User query to search the web
|
| 17 |
"""
|
| 18 |
print("RK test inside function")
|
| 19 |
+
# query_result=DuckDuckGoSearchTool.forward(query)
|
| 20 |
+
# return query_result
|
| 21 |
+
try:
|
| 22 |
+
web_search_tool = DuckDuckGoSearchTool()
|
| 23 |
+
results = web_search_tool.forward(query)
|
| 24 |
+
|
| 25 |
+
visit_webpage_tool = VisitWebpageTool()
|
| 26 |
+
|
| 27 |
+
ranked_results = rank_urls_by_relevance(results, query)
|
| 28 |
+
|
| 29 |
+
page_content = visit_webpage_tool.forward(ranked_results[0][0][1])
|
| 30 |
+
|
| 31 |
+
return page_content
|
| 32 |
+
|
| 33 |
+
except Exception as e:
|
| 34 |
+
return f"Error fetching results"
|
| 35 |
|
| 36 |
@tool
|
| 37 |
def get_current_time_in_timezone(timezone: str) -> str:
|