Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -18,14 +18,15 @@ def get_btc_price() -> str:
|
|
| 18 |
|
| 19 |
@tool
|
| 20 |
def get_btc_news() -> str:
|
| 21 |
-
"""Fetches
|
| 22 |
-
search_query = "Bitcoin news"
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
|
|
|
| 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,
|