Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,14 +19,16 @@ def get_stock_news(symbol: str)-> str: #it's import to specify the return type
|
|
| 19 |
"""
|
| 20 |
search_tool = DuckDuckGoSearchTool()
|
| 21 |
|
| 22 |
-
api_key = os.getenv("MKTAUX_API_KEY")
|
| 23 |
-
|
|
|
|
|
|
|
| 24 |
|
| 25 |
response = requests.get(url)
|
| 26 |
data = response.json()
|
| 27 |
|
| 28 |
-
if
|
| 29 |
-
|
| 30 |
else:
|
| 31 |
return None
|
| 32 |
|
|
@@ -68,7 +70,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 68 |
|
| 69 |
agent = CodeAgent(
|
| 70 |
model=model,
|
| 71 |
-
tools=[final_answer,search_tool,get_stock_news], ## add your tools here (don't remove final answer)
|
| 72 |
max_steps=6,
|
| 73 |
verbosity_level=1,
|
| 74 |
grammar=None,
|
|
|
|
| 19 |
"""
|
| 20 |
search_tool = DuckDuckGoSearchTool()
|
| 21 |
|
| 22 |
+
api_key = os.getenv("MKTAUX_API_KEY", "YOUR_DEFAULT_API_KEY")
|
| 23 |
+
if not api_key:
|
| 24 |
+
raise ValueError("API key is missing! Set MKTAUX_API_KEY in your environment.")
|
| 25 |
+
url = f"https://api.marketaux.com/v1/news/all?symbols={symbol}&filter_entities=true&language=en&api_token={api_key}"
|
| 26 |
|
| 27 |
response = requests.get(url)
|
| 28 |
data = response.json()
|
| 29 |
|
| 30 |
+
if "data" in data and len(data["data"]) > 0:
|
| 31 |
+
return data["data"][0].get("description", "No description available")
|
| 32 |
else:
|
| 33 |
return None
|
| 34 |
|
|
|
|
| 70 |
|
| 71 |
agent = CodeAgent(
|
| 72 |
model=model,
|
| 73 |
+
tools=[final_answer,search_tool,get_stock_news,get_current_time_in_timezone], ## add your tools here (don't remove final answer)
|
| 74 |
max_steps=6,
|
| 75 |
verbosity_level=1,
|
| 76 |
grammar=None,
|