Yudum commited on
Commit
0ba394e
·
verified ·
1 Parent(s): d2db0f7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -13
app.py CHANGED
@@ -8,27 +8,21 @@ from tools.final_answer import FinalAnswerTool
8
  from Gradio_UI import GradioUI
9
 
10
  @tool
11
- def fetch_duckduckgo_summary(query: str) -> str:
12
  """
13
- Fetches a short summary from web search results.
14
 
15
  Args:
16
- query (str): The search query.
17
 
18
  Returns:
19
- str: A brief summary of the top search results.
20
  """
21
  try:
22
  # Perform a DuckDuckGo search
23
- search_tool = DuckDuckGoSearchTool()
24
- search_results = search_tool(query=query, max_results=3)
25
 
26
- # Extract the top results
27
- if search_results and isinstance(search_results, list):
28
- summary = "\n".join([f"{res['title']}: {res.get('body', 'No description')}" for res in search_results])
29
- return summary
30
- else:
31
- return "No relevant results found."
32
 
33
  except Exception as e:
34
  return f"Error fetching search results: {str(e)}"
@@ -70,7 +64,7 @@ with open("prompts.yaml", 'r') as stream:
70
 
71
  agent = CodeAgent(
72
  model=model,
73
- tools=[generate_image_from_wikipedia, get_current_time_in_timezone, final_answer], ## add your tools here (don't remove final answer)
74
  max_steps=6,
75
  verbosity_level=1,
76
  grammar=None,
 
8
  from Gradio_UI import GradioUI
9
 
10
  @tool
11
+ def dream_image_generator(dream_desc: str) -> str:
12
  """
13
+ Generates an image of an dream based on user description.
14
 
15
  Args:
16
+ dream_desc (str): Dream description.
17
 
18
  Returns:
19
+ str: URL or path to the AI-generated dream image.
20
  """
21
  try:
22
  # Perform a DuckDuckGo search
23
+ dream_image = image_generation_tool(f"A surreal dream {dream_desc}")
 
24
 
25
+ return dream_image
 
 
 
 
 
26
 
27
  except Exception as e:
28
  return f"Error fetching search results: {str(e)}"
 
64
 
65
  agent = CodeAgent(
66
  model=model,
67
+ tools=[dream_image_generator, get_current_time_in_timezone, final_answer], ## add your tools here (don't remove final answer)
68
  max_steps=6,
69
  verbosity_level=1,
70
  grammar=None,