Spaces:
Sleeping
Sleeping
Update app.py
Browse filesadded get_equity_symbol() function
app.py
CHANGED
|
@@ -4,20 +4,31 @@ import requests
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
|
|
|
|
|
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
@tool
|
| 12 |
-
def
|
| 13 |
-
|
| 14 |
-
"""A tool that does nothing yet
|
| 15 |
Args:
|
| 16 |
-
|
| 17 |
-
arg2: the second argument
|
| 18 |
"""
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
|
|
|
|
|
|
|
|
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 23 |
"""A tool that fetches the current local time in a specified timezone.
|
|
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
+
import pandas as pd
|
| 8 |
+
import os
|
| 9 |
|
| 10 |
from Gradio_UI import GradioUI
|
| 11 |
|
| 12 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 13 |
@tool
|
| 14 |
+
def get_equity_symbol(keyword:str)-> str:
|
| 15 |
+
"""A tool that search the symbol of equity (company).
|
|
|
|
| 16 |
Args:
|
| 17 |
+
equity_name: name of the equity or company
|
|
|
|
| 18 |
"""
|
| 19 |
+
AlPHA_VANTAGE_KEY = os.getenv('ALPHA_VANTAGE_KEY')
|
| 20 |
+
url = f'https://www.alphavantage.co/query?function=SYMBOL_SEARCH&keywords={keyword}&apikey={AlPHA_VANTAGE_KEY}'
|
| 21 |
+
response = requests.get(url)
|
| 22 |
+
data = response.json()
|
| 23 |
+
filtered_data = []
|
| 24 |
+
for data in data:
|
| 25 |
+
filtered_data.append({'symbol':data['1. symbol'],'rejion':data['4. region']})
|
| 26 |
+
|
| 27 |
+
return filtered_data
|
| 28 |
|
| 29 |
+
|
| 30 |
+
@tool
|
| 31 |
+
def
|
| 32 |
@tool
|
| 33 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 34 |
"""A tool that fetches the current local time in a specified timezone.
|