Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -35,6 +35,33 @@ def get_stock_information(stock:str) -> str:
|
|
| 35 |
return f"Error fetching stock info '{stock}': {str(e)}"
|
| 36 |
pass
|
| 37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
@tool
|
| 39 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 40 |
"""A tool that fetches the current local time in a specified timezone.
|
|
@@ -72,7 +99,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 72 |
|
| 73 |
agent = CodeAgent(
|
| 74 |
model=model,
|
| 75 |
-
tools=[final_answer,get_stock_information], ## add your tools here (don't remove final answer)
|
| 76 |
max_steps=6,
|
| 77 |
verbosity_level=1,
|
| 78 |
grammar=None,
|
|
|
|
| 35 |
return f"Error fetching stock info '{stock}': {str(e)}"
|
| 36 |
pass
|
| 37 |
|
| 38 |
+
@tool
|
| 39 |
+
def get_radion_str(country:str)->str:
|
| 40 |
+
''' this function fetches streams to radio stations for countrys
|
| 41 |
+
|
| 42 |
+
Args input: Country str ex: get_radion_str('us')
|
| 43 |
+
Output: Str of radio streams
|
| 44 |
+
|
| 45 |
+
'''
|
| 46 |
+
try:
|
| 47 |
+
conn = http.client.HTTPSConnection("50k-radio-stations.p.rapidapi.com")
|
| 48 |
+
|
| 49 |
+
headers = {
|
| 50 |
+
'x-rapidapi-key': "edb18a5d52msh741fb6d677c3be2p1c3c92jsn41ac9a131361",
|
| 51 |
+
'x-rapidapi-host': "50k-radio-stations.p.rapidapi.com",
|
| 52 |
+
'Content-Type': "application/json"
|
| 53 |
+
}
|
| 54 |
+
conn.request("GET", f"/radios/popular/{country}?limit=4", headers=headers)
|
| 55 |
+
|
| 56 |
+
res = conn.getresponse()
|
| 57 |
+
data = res.read()
|
| 58 |
+
strms=[dt['data'][vl]['streams'][0]['url'] for vl in range(len(dt['data']))]
|
| 59 |
+
print(f'''********Region {country}******** \n," \n".join(strms)''')
|
| 60 |
+
except Exception as e:
|
| 61 |
+
return f"Error fetching music, trying singng yourself {str(e)}"
|
| 62 |
+
pass
|
| 63 |
+
|
| 64 |
+
|
| 65 |
@tool
|
| 66 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 67 |
"""A tool that fetches the current local time in a specified timezone.
|
|
|
|
| 99 |
|
| 100 |
agent = CodeAgent(
|
| 101 |
model=model,
|
| 102 |
+
tools=[final_answer,get_stock_information,get_radion_str], ## add your tools here (don't remove final answer)
|
| 103 |
max_steps=6,
|
| 104 |
verbosity_level=1,
|
| 105 |
grammar=None,
|