Spaces:
Sleeping
Sleeping
fix seach-result tool
Browse files
app.py
CHANGED
|
@@ -76,13 +76,15 @@ import pytz
|
|
| 76 |
import requests
|
| 77 |
import yaml
|
| 78 |
import spaces
|
| 79 |
-
from smolagents import CodeAgent,
|
| 80 |
#from tools.final_answer import FinalAnswerTool
|
| 81 |
from Gradio_UI import GradioUI
|
|
|
|
| 82 |
|
| 83 |
# Gloable vars and important stuff:
|
| 84 |
|
| 85 |
search_tool = DuckDuckGoSearchTool() #for search tool # the easy way.
|
|
|
|
| 86 |
final_answer = FinalAnswerTool() #final answer tool
|
| 87 |
# image generation tool
|
| 88 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
|
@@ -115,9 +117,9 @@ def my_custom_tool(arg1: str, arg2: int) -> str:
|
|
| 115 |
@tool
|
| 116 |
def hbty(b_day: str) -> str: #hbty = Happy Birthday to you
|
| 117 |
"""
|
| 118 |
-
A tool for wishing Happy Birthday, If use query or inputs have keyword "birthday".
|
| 119 |
Args:
|
| 120 |
-
b_day
|
| 121 |
"""
|
| 122 |
#return "Happy Birthday To You !!!! :)"
|
| 123 |
cleaned_input = b_day.lower()
|
|
@@ -147,8 +149,10 @@ def get_search_results(query: str) -> str:
|
|
| 147 |
"""
|
| 148 |
try:
|
| 149 |
# DuckDuckGoSearchTool is callable directly with the query string
|
| 150 |
-
search_results = _ddg_search(query)
|
| 151 |
-
return search_results
|
|
|
|
|
|
|
| 152 |
except Exception as e:
|
| 153 |
return f"Error executing search query '{query}': {str(e)}"
|
| 154 |
|
|
|
|
| 76 |
import requests
|
| 77 |
import yaml
|
| 78 |
import spaces
|
| 79 |
+
from smolagents import CodeAgent, HfApiModel, load_tool, tool, FinalAnswerTool #, InferenceClientModel, DuckDuckGoSearchTool
|
| 80 |
#from tools.final_answer import FinalAnswerTool
|
| 81 |
from Gradio_UI import GradioUI
|
| 82 |
+
from duckduckgo_search import DDGS # or: from ddgs import DDGS
|
| 83 |
|
| 84 |
# Gloable vars and important stuff:
|
| 85 |
|
| 86 |
search_tool = DuckDuckGoSearchTool() #for search tool # the easy way.
|
| 87 |
+
#search_results = _ddg_search(query)
|
| 88 |
final_answer = FinalAnswerTool() #final answer tool
|
| 89 |
# image generation tool
|
| 90 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
|
|
|
| 117 |
@tool
|
| 118 |
def hbty(b_day: str) -> str: #hbty = Happy Birthday to you
|
| 119 |
"""
|
| 120 |
+
A tool for wishing Happy Birthday, If use query or inputs have or contain keyword "birthday" or "bday".
|
| 121 |
Args:
|
| 122 |
+
b_day: A string containing a question or statement to check for birthday keywords like 'birthday' or 'bday'.
|
| 123 |
"""
|
| 124 |
#return "Happy Birthday To You !!!! :)"
|
| 125 |
cleaned_input = b_day.lower()
|
|
|
|
| 149 |
"""
|
| 150 |
try:
|
| 151 |
# DuckDuckGoSearchTool is callable directly with the query string
|
| 152 |
+
#search_results = _ddg_search(query)
|
| 153 |
+
#return search_results
|
| 154 |
+
results = ddg_client.text(query, max_results=5)
|
| 155 |
+
return str(results)
|
| 156 |
except Exception as e:
|
| 157 |
return f"Error executing search query '{query}': {str(e)}"
|
| 158 |
|