Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,6 +2,7 @@ from smolagents import CodeAgent, HfApiModel, tool
|
|
| 2 |
import requests
|
| 3 |
from tools.final_answer import FinalAnswerTool
|
| 4 |
from Gradio_UI import GradioUI
|
|
|
|
| 5 |
|
| 6 |
@tool
|
| 7 |
def get_btc_price() -> str:
|
|
@@ -35,6 +36,22 @@ def get_btc_confidence_conseils(price: str) -> str:
|
|
| 35 |
else:
|
| 36 |
return f"Market analysis ({price}): Bearish trend detected. Consider selling."
|
| 37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
# Initialize the agent with all tools
|
| 39 |
agent = CodeAgent(
|
| 40 |
model=HfApiModel(
|
|
@@ -42,7 +59,7 @@ agent = CodeAgent(
|
|
| 42 |
max_tokens=2096,
|
| 43 |
temperature=0.5
|
| 44 |
),
|
| 45 |
-
tools=[get_btc_price, get_btc_confidence_conseils, FinalAnswerTool()],
|
| 46 |
max_steps=6,
|
| 47 |
verbosity_level=1
|
| 48 |
)
|
|
|
|
| 2 |
import requests
|
| 3 |
from tools.final_answer import FinalAnswerTool
|
| 4 |
from Gradio_UI import GradioUI
|
| 5 |
+
from duckduckgo_search import duckduckgo_search
|
| 6 |
|
| 7 |
@tool
|
| 8 |
def get_btc_price() -> str:
|
|
|
|
| 36 |
else:
|
| 37 |
return f"Market analysis ({price}): Bearish trend detected. Consider selling."
|
| 38 |
|
| 39 |
+
@tool
|
| 40 |
+
def get_btc_info(query: str) -> str:
|
| 41 |
+
"""Gathers information on Bitcoin using DuckDuckGo search.
|
| 42 |
+
|
| 43 |
+
Args:
|
| 44 |
+
query (str): Search query related to Bitcoin (e.g., "Bitcoin price", "Bitcoin news")
|
| 45 |
+
|
| 46 |
+
Returns:
|
| 47 |
+
str: Relevant information on Bitcoin based on the search query
|
| 48 |
+
"""
|
| 49 |
+
results = duckduckgo_search(query, user_agent='Mozilla/5.0', max_results=5)
|
| 50 |
+
info = ""
|
| 51 |
+
for result in results:
|
| 52 |
+
info += f"{result['title']}: {result['url']}\n"
|
| 53 |
+
return info
|
| 54 |
+
|
| 55 |
# Initialize the agent with all tools
|
| 56 |
agent = CodeAgent(
|
| 57 |
model=HfApiModel(
|
|
|
|
| 59 |
max_tokens=2096,
|
| 60 |
temperature=0.5
|
| 61 |
),
|
| 62 |
+
tools=[get_btc_price, get_btc_confidence_conseils, get_btc_info, FinalAnswerTool()],
|
| 63 |
max_steps=6,
|
| 64 |
verbosity_level=1
|
| 65 |
)
|