latif98 commited on
Commit
a58a41e
·
verified ·
1 Parent(s): 3b2dfc8

Update app.py

Browse files

added get_equity_symbol() function

Files changed (1) hide show
  1. app.py +17 -6
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 my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
13
- #Keep this format for the description / args / args description but feel free to modify the tool
14
- """A tool that does nothing yet
15
  Args:
16
- arg1: the first argument
17
- arg2: the second argument
18
  """
19
- return "What magic will you build ?"
 
 
 
 
 
 
 
 
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.