Mtchmann commited on
Commit
62ed523
·
verified ·
1 Parent(s): 41d6504

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -33,6 +33,7 @@ def get_current_time_in_timezone(timezone: str) -> str:
33
  except Exception as e:
34
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
35
 
 
36
  @tool
37
  def deepresearch(query: str, depth: int = 2) -> str:
38
  """A tool that performs deep research on a given topic using iterative searches.
@@ -41,15 +42,16 @@ def deepresearch(query: str, depth: int = 2) -> str:
41
  depth: The number of iterative search steps to perform (default is 2).
42
  """
43
  research_results = []
44
- # Perform the initial search with the provided query
45
- initial_result = DuckDuckGoSearchTool(query)
 
46
  research_results.append(f"Initial search:\n{initial_result}")
47
-
48
- # If a deeper level of research is requested, perform additional searches
49
  for i in range(1, depth):
50
  #Modify the query slightly for additional detail
51
  detailed_query = f"{query} analysis part {i}"
52
- detailed_result = DuckDuckGoSearchTool(detailed_query)
53
  research_results.append(f"Additional research (iteration {i}:\n{detailed_result}")
54
 
55
  # Aggregate all the search results into one comprehensive answer
@@ -75,7 +77,7 @@ agent = CodeAgent(
75
  model=model,
76
  tools=[
77
  final_answer,
78
- DuckDuckGoSearchTool,
79
  image_generation_tool,
80
  my_custom_tool,
81
  get_current_time_in_timezone,
 
33
  except Exception as e:
34
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
35
 
36
+ # New DeepResearch Tool
37
  @tool
38
  def deepresearch(query: str, depth: int = 2) -> str:
39
  """A tool that performs deep research on a given topic using iterative searches.
 
42
  depth: The number of iterative search steps to perform (default is 2).
43
  """
44
  research_results = []
45
+ # Create an instance of DuckDuckGoSearchTool
46
+ search_tool = DuckDuckGoSearchTool()
47
+ initial_result = search_tool(query)
48
  research_results.append(f"Initial search:\n{initial_result}")
49
+
50
+ # Perform additional iterations for deeper research
51
  for i in range(1, depth):
52
  #Modify the query slightly for additional detail
53
  detailed_query = f"{query} analysis part {i}"
54
+ detailed_result = search_tool(detailed_query)
55
  research_results.append(f"Additional research (iteration {i}:\n{detailed_result}")
56
 
57
  # Aggregate all the search results into one comprehensive answer
 
77
  model=model,
78
  tools=[
79
  final_answer,
80
+ DuckDuckGoSearchTool(),
81
  image_generation_tool,
82
  my_custom_tool,
83
  get_current_time_in_timezone,