bako96 commited on
Commit
11458ef
·
verified ·
1 Parent(s): 5091c6d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -18
app.py CHANGED
@@ -15,24 +15,17 @@ def get_youtube_channel_info(channel_name: str) -> str:
15
  channel_name: The name of the YouTube channel to search for.
16
  """
17
  try:
18
- # Use DuckDuckGoSearchTool to search for the YouTube channel
19
- search_tool = DuckDuckGoSearchTool()
20
  query = f"{channel_name} YouTube channel information"
21
- #print(f"Searching for: {query}") # Debug print statement
22
- search_results = search_tool(query)
23
-
24
- # Print all search results for debugging
25
- #print(f"Search results for '{channel_name}': {search_results}")
26
-
27
- # Extract and return the top result
28
- if search_results and len(search_results) > 0:
29
- top_result = search_results[0] # Get the first result
30
- print("type *** ", type(top_result))
31
- print(f"Top search result: {top_result}") # Debug print statement
32
- return f"Top search result for '{channel_name}': {top_result}"
33
- else:
34
- print(f"No results found for '{channel_name}'.") # Debug print statement
35
- return f"No information found for YouTube channel '{channel_name}'."
36
  except Exception as e:
37
  print(f"Error occurred while searching for '{channel_name}': {str(e)}") # Debug print statement
38
  return f"Error fetching YouTube channel information: {str(e)}"
@@ -73,7 +66,7 @@ with open("prompts.yaml", 'r') as stream:
73
 
74
  agent = CodeAgent(
75
  model=model,
76
- tools=[get_youtube_channel_info, get_current_time_in_timezone, final_answer,], # Add tools here
77
  max_steps=6,
78
  verbosity_level=1,
79
  grammar=None,
 
15
  channel_name: The name of the YouTube channel to search for.
16
  """
17
  try:
18
+ # Initialize DuckDuckGoSearchTool with a maximum of 5 results
19
+ search_tool = DuckDuckGoSearchTool(max_results=5)
20
  query = f"{channel_name} YouTube channel information"
21
+ print(f"Searching for: {query}") # Debug print statement
22
+
23
+ # Perform the search
24
+ search_results = search_tool.forward(query)
25
+ print(f"Raw search results:\n{search_results}") # Debug print statement
26
+
27
+ # Return the formatted search results
28
+ return f"Search results for '{channel_name}':\n\n{search_results}"
 
 
 
 
 
 
 
29
  except Exception as e:
30
  print(f"Error occurred while searching for '{channel_name}': {str(e)}") # Debug print statement
31
  return f"Error fetching YouTube channel information: {str(e)}"
 
66
 
67
  agent = CodeAgent(
68
  model=model,
69
+ tools=[final_answer, get_youtube_channel_info, get_current_time_in_timezone], # Add tools here
70
  max_steps=6,
71
  verbosity_level=1,
72
  grammar=None,