Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -33,6 +33,21 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
33 |
except Exception as e:
|
34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
final_answer = FinalAnswerTool()
|
38 |
|
@@ -60,6 +75,7 @@ agent = CodeAgent(
|
|
60 |
final_answer,
|
61 |
image_generation_tool,
|
62 |
get_current_time_in_timezone,
|
|
|
63 |
], ## add your tools here (don't remove final answer)
|
64 |
max_steps=6,
|
65 |
verbosity_level=1,
|
|
|
33 |
except Exception as e:
|
34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
35 |
|
36 |
+
@tool
|
37 |
+
def get_page_in_quran(page: int) -> str:
|
38 |
+
"""A tool that fetches a specific page of the quran.
|
39 |
+
Args:
|
40 |
+
page: An integer representing a valid page of the quran (e.g., 12).
|
41 |
+
"""
|
42 |
+
try:
|
43 |
+
api_url = f"http://api.alquran.cloud/v1/page/{page}/en.asad"
|
44 |
+
# Get contents of the page
|
45 |
+
content = requests.get(api_url)
|
46 |
+
if response.status_code == 200:
|
47 |
+
data = response.json()
|
48 |
+
return data.get("data", f"No data available for page: {page} in the quran")
|
49 |
+
except Exception as e:
|
50 |
+
return f"Error fetching page '{page}' of the quran: {str(e)}"
|
51 |
|
52 |
final_answer = FinalAnswerTool()
|
53 |
|
|
|
75 |
final_answer,
|
76 |
image_generation_tool,
|
77 |
get_current_time_in_timezone,
|
78 |
+
get_page_in_quran,
|
79 |
], ## add your tools here (don't remove final answer)
|
80 |
max_steps=6,
|
81 |
verbosity_level=1,
|