Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -42,14 +42,15 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 42 |
@tool
|
| 43 |
def get_current_stock_price(ticker_symbol: str) -> Optional[dict]:
|
| 44 |
"""
|
| 45 |
-
|
| 46 |
-
the price change over the last 5 days
|
|
|
|
| 47 |
|
| 48 |
Args:
|
| 49 |
ticker_symbol: The stock ticker symbol to fetch the price for.
|
| 50 |
|
| 51 |
Returns:
|
| 52 |
-
dict: A dictionary containing the current stock price, the price change
|
| 53 |
over the last 5 days, and the percentage change.
|
| 54 |
Returns None if there's an error or no data is available.
|
| 55 |
"""
|
|
@@ -69,11 +70,12 @@ def get_current_stock_price(ticker_symbol: str) -> Optional[dict]:
|
|
| 69 |
price_change_percent = (price_change / stock_data['Close'].iloc[0]) * 100
|
| 70 |
|
| 71 |
# Round all values to 2 decimal places
|
| 72 |
-
|
| 73 |
"price": round(current_price, 2),
|
| 74 |
"price_change": round(price_change, 2),
|
| 75 |
"price_change_percent": round(price_change_percent, 2)
|
| 76 |
}
|
|
|
|
| 77 |
|
| 78 |
except yf.exceptions.YFinanceException as yf_err:
|
| 79 |
logger.error(f"YFinance error for {ticker_symbol}: {str(yf_err)}")
|
|
@@ -94,7 +96,7 @@ custom_role_conversions=None,
|
|
| 94 |
)
|
| 95 |
|
| 96 |
# Import tool from Hub
|
| 97 |
-
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 98 |
|
| 99 |
with open("prompts.yaml", 'r') as stream:
|
| 100 |
prompt_templates = yaml.safe_load(stream)
|
|
|
|
| 42 |
@tool
|
| 43 |
def get_current_stock_price(ticker_symbol: str) -> Optional[dict]:
|
| 44 |
"""
|
| 45 |
+
Get the latest stock price for the given ticker symbol and calculates
|
| 46 |
+
the price change over the last 5 days and retrun current stock price ,
|
| 47 |
+
price change and percentage change.
|
| 48 |
|
| 49 |
Args:
|
| 50 |
ticker_symbol: The stock ticker symbol to fetch the price for.
|
| 51 |
|
| 52 |
Returns:
|
| 53 |
+
price -> dict: A dictionary containing the current stock price, the price change
|
| 54 |
over the last 5 days, and the percentage change.
|
| 55 |
Returns None if there's an error or no data is available.
|
| 56 |
"""
|
|
|
|
| 70 |
price_change_percent = (price_change / stock_data['Close'].iloc[0]) * 100
|
| 71 |
|
| 72 |
# Round all values to 2 decimal places
|
| 73 |
+
price = {
|
| 74 |
"price": round(current_price, 2),
|
| 75 |
"price_change": round(price_change, 2),
|
| 76 |
"price_change_percent": round(price_change_percent, 2)
|
| 77 |
}
|
| 78 |
+
return price
|
| 79 |
|
| 80 |
except yf.exceptions.YFinanceException as yf_err:
|
| 81 |
logger.error(f"YFinance error for {ticker_symbol}: {str(yf_err)}")
|
|
|
|
| 96 |
)
|
| 97 |
|
| 98 |
# Import tool from Hub
|
| 99 |
+
# image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 100 |
|
| 101 |
with open("prompts.yaml", 'r') as stream:
|
| 102 |
prompt_templates = yaml.safe_load(stream)
|