Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -19,26 +19,32 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
|
|
19 |
return "What magic will you build ?"
|
20 |
|
21 |
@tool
|
22 |
-
def
|
23 |
-
"""
|
|
|
24 |
|
25 |
Args:
|
26 |
query: The search query string.
|
27 |
-
|
28 |
|
29 |
Returns:
|
30 |
-
A
|
31 |
"""
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
@tool
|
44 |
def get_current_time_in_timezone(timezone: str) -> str:
|
@@ -77,7 +83,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
77 |
|
78 |
agent = CodeAgent(
|
79 |
model=model,
|
80 |
-
tools=[final_answer,
|
81 |
max_steps=6,
|
82 |
verbosity_level=1,
|
83 |
grammar=None,
|
|
|
19 |
return "What magic will you build ?"
|
20 |
|
21 |
@tool
|
22 |
+
def duckduck_tool(query: str, num_results: int = 5) -> str:
|
23 |
+
"""
|
24 |
+
A tool that uses DuckDuckGo search to retrieve the latest information and webpage content for a given query.
|
25 |
|
26 |
Args:
|
27 |
query: The search query string.
|
28 |
+
num_results: The number of search results to return (default is 5).
|
29 |
|
30 |
Returns:
|
31 |
+
A string summarizing the latest information and webpage content related to the query.
|
32 |
"""
|
33 |
+
# Perform a DuckDuckGo search using a hypothetical 'duckduckgosearch' function
|
34 |
+
search_results = duckduckgosearch(query, num_results)
|
35 |
+
|
36 |
+
# Initialize an empty string to collect webpage content
|
37 |
+
combined_content = ""
|
38 |
+
|
39 |
+
# Loop through each search result to fetch its webpage content using a hypothetical 'get_webpage_content' function
|
40 |
+
for result in search_results:
|
41 |
+
webpage_content = get_webpage_content(result.url)
|
42 |
+
combined_content += webpage_content + "\n"
|
43 |
+
|
44 |
+
# Generate a summary answer from the combined content using a hypothetical 'generate_summary' function
|
45 |
+
summary_answer = generate_summary(combined_content)
|
46 |
+
|
47 |
+
return summary_answer
|
48 |
|
49 |
@tool
|
50 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
83 |
|
84 |
agent = CodeAgent(
|
85 |
model=model,
|
86 |
+
tools=[final_answer, duckduck_tool], ## add your tools here (don't remove final answer)
|
87 |
max_steps=6,
|
88 |
verbosity_level=1,
|
89 |
grammar=None,
|