zerito commited on
Commit
b196de8
·
verified ·
1 Parent(s): abff7c0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -8
app.py CHANGED
@@ -18,14 +18,15 @@ def get_btc_price() -> str:
18
 
19
  @tool
20
  def get_btc_news() -> str:
21
- """Fetches recent Bitcoin news articles using DuckDuckGo search."""
22
- search_query = "Bitcoin news"
23
- search_tool = DuckDuckGoSearchTool()
24
- results = search_tool(search_query)
25
- if not results:
26
- return "No news articles found."
27
- news = "\n".join([f"{i+1}. {result['title']} - {result['url']}" for i, result in enumerate(results[:5])])
28
- return f"Recent Bitcoin News:\n{news}"
 
29
 
30
  # Initialize the FinalAnswerTool
31
  final_answer = FinalAnswerTool()
@@ -38,6 +39,10 @@ model = HfApiModel(
38
  custom_role_conversions=None,
39
  )
40
 
 
 
 
 
41
  # Create the agent
42
  agent = CodeAgent(
43
  model=model,
 
18
 
19
  @tool
20
  def get_btc_news() -> str:
21
+ """Fetches the latest Bitcoin news articles."""
22
+ search_query = "latest Bitcoin news"
23
+ search_results = DuckDuckGoSearchTool()(search_query)
24
+ if not search_results:
25
+ return '{"error": "Failed to fetch Bitcoin news"}'
26
+ news_titles = [result['title'] for result in search_results]
27
+ news_descriptions = [result['snippet'] for result in search_results]
28
+ news_list = "\n".join([f"**{title}**\n{description}" for title, description in zip(news_titles, news_descriptions)])
29
+ return f"Here are the latest Bitcoin news articles:\n\n{news_list}"
30
 
31
  # Initialize the FinalAnswerTool
32
  final_answer = FinalAnswerTool()
 
39
  custom_role_conversions=None,
40
  )
41
 
42
+ # Load additional tools if needed
43
+ # For example, to load an image generation tool:
44
+ # image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
45
+
46
  # Create the agent
47
  agent = CodeAgent(
48
  model=model,