Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,32 +8,31 @@ from Gradio_UI import GradioUI
|
|
| 8 |
|
| 9 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 10 |
@tool
|
| 11 |
-
def pull_rates(
|
| 12 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
| 13 |
"""A tool that fetches the latest interest or treasury rate from FRED.
|
| 14 |
Args:
|
| 15 |
-
|
| 16 |
"""
|
| 17 |
|
| 18 |
# Dictionary mapping user-friendly tenors to their FRED IDs.
|
| 19 |
-
yield_curve_ids = {
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
"30 Year": "DGS30"}
|
| 32 |
|
| 33 |
-
|
| 34 |
-
|
| 35 |
# Build the URL for the CSV on the FRED website
|
| 36 |
fred_api_url = f"https://fred.stlouisfed.org/graph/fredgraph.csv?id={fred_id}"
|
|
|
|
| 37 |
try:
|
| 38 |
import pandas as pd
|
| 39 |
# Create timezone object
|
|
|
|
| 8 |
|
| 9 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 10 |
@tool
|
| 11 |
+
def pull_rates(fred_id: str)-> str: #it's import to specify the return type
|
| 12 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
| 13 |
"""A tool that fetches the latest interest or treasury rate from FRED.
|
| 14 |
Args:
|
| 15 |
+
fred_id: a string representing a valid insterst rate code to pull from the FRED website
|
| 16 |
"""
|
| 17 |
|
| 18 |
# Dictionary mapping user-friendly tenors to their FRED IDs.
|
| 19 |
+
yield_curve_ids = {'SOFR': 'SOFR',
|
| 20 |
+
'DGS1MO': '1 Month',
|
| 21 |
+
'DGS3MO': '3 Month',
|
| 22 |
+
'DGS6MO': '6 Month',
|
| 23 |
+
'DGS1': '1 Year',
|
| 24 |
+
'DGS2': '2 Year',
|
| 25 |
+
'DGS3': '3 Year',
|
| 26 |
+
'DGS5': '5 Year',
|
| 27 |
+
'DGS7': '7 Year',
|
| 28 |
+
'DGS10': '10 Year',
|
| 29 |
+
'DGS20': '20 Year',
|
| 30 |
+
'DGS30': '30 Year'}
|
|
|
|
| 31 |
|
| 32 |
+
english_fred_id = yield_curve_ids[fred_id]
|
|
|
|
| 33 |
# Build the URL for the CSV on the FRED website
|
| 34 |
fred_api_url = f"https://fred.stlouisfed.org/graph/fredgraph.csv?id={fred_id}"
|
| 35 |
+
|
| 36 |
try:
|
| 37 |
import pandas as pd
|
| 38 |
# Create timezone object
|