Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,6 +9,19 @@ from Gradio_UI import GradioUI
|
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
@tool
|
| 13 |
def calculator(expression: str) -> str:
|
| 14 |
"""Evaluate a basic math expression safely.
|
|
@@ -61,8 +74,6 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 61 |
|
| 62 |
final_answer = FinalAnswerTool()
|
| 63 |
|
| 64 |
-
search_tool = DuckDuckGoSearchTool()
|
| 65 |
-
|
| 66 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|
| 67 |
# model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
|
| 68 |
|
|
@@ -83,7 +94,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 83 |
agent = CodeAgent(
|
| 84 |
model=model,
|
| 85 |
tools=[
|
| 86 |
-
|
| 87 |
get_current_time_in_timezone,
|
| 88 |
image_generation_tool,
|
| 89 |
get_exchange_rate,
|
|
|
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
|
| 12 |
+
# Create a single instance of the DDG tool (so it can be reused)
|
| 13 |
+
ddg = DuckDuckGoSearchTool()
|
| 14 |
+
|
| 15 |
+
@tool
|
| 16 |
+
def web_search(query: str) -> str:
|
| 17 |
+
"""Search the public web using DuckDuckGo.
|
| 18 |
+
Use this tool whenever the user asks for information found on the internet
|
| 19 |
+
(news, definitions, comparisons, current info, Hugging Face updates, etc.)
|
| 20 |
+
Args:
|
| 21 |
+
query: The search query.
|
| 22 |
+
"""
|
| 23 |
+
return ddg(query)
|
| 24 |
+
|
| 25 |
@tool
|
| 26 |
def calculator(expression: str) -> str:
|
| 27 |
"""Evaluate a basic math expression safely.
|
|
|
|
| 74 |
|
| 75 |
final_answer = FinalAnswerTool()
|
| 76 |
|
|
|
|
|
|
|
| 77 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|
| 78 |
# model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
|
| 79 |
|
|
|
|
| 94 |
agent = CodeAgent(
|
| 95 |
model=model,
|
| 96 |
tools=[
|
| 97 |
+
web_search,
|
| 98 |
get_current_time_in_timezone,
|
| 99 |
image_generation_tool,
|
| 100 |
get_exchange_rate,
|