Spaces:
Paused
Paused
Update the ayah tool
Browse files
app.py
CHANGED
|
@@ -9,7 +9,7 @@ from Gradio_UI import GradioUI
|
|
| 9 |
|
| 10 |
@tool
|
| 11 |
def get_quran_ayah(surah_number: int, ayah_number: int) -> str:
|
| 12 |
-
"""Fetches a specific ayah from the Quran API for the specified surah and ayah numbers.
|
| 13 |
Args:
|
| 14 |
surah_number: The surah number.
|
| 15 |
ayah_number: The ayah number.
|
|
@@ -18,13 +18,16 @@ def get_quran_ayah(surah_number: int, ayah_number: int) -> str:
|
|
| 18 |
|
| 19 |
try:
|
| 20 |
response = requests.get(url)
|
| 21 |
-
response.raise_for_status()
|
| 22 |
data = response.json()
|
| 23 |
arabic_text = data["data"][0]["text"]
|
| 24 |
english_text = data["data"][1]["text"]
|
| 25 |
-
return f"The text for ayah {
|
| 26 |
except requests.RequestException as e:
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
@tool
|
| 30 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 9 |
|
| 10 |
@tool
|
| 11 |
def get_quran_ayah(surah_number: int, ayah_number: int) -> str:
|
| 12 |
+
"""Fetches a specific ayah arabic and translation textes from the Quran API for the specified surah and ayah numbers.
|
| 13 |
Args:
|
| 14 |
surah_number: The surah number.
|
| 15 |
ayah_number: The ayah number.
|
|
|
|
| 18 |
|
| 19 |
try:
|
| 20 |
response = requests.get(url)
|
| 21 |
+
response.raise_for_status()
|
| 22 |
data = response.json()
|
| 23 |
arabic_text = data["data"][0]["text"]
|
| 24 |
english_text = data["data"][1]["text"]
|
| 25 |
+
return f"The text for ayah {ayah_number} of surah {surah_number} is:\nArabic: {arabic_text}\nEnglish: {english_text}"
|
| 26 |
except requests.RequestException as e:
|
| 27 |
+
response_data = response.json()
|
| 28 |
+
if response_data.get("status") == "NOT FOUND":
|
| 29 |
+
return f"Error: NOT FOUND - Invalid surah/ayah reference ({surah_number}:{ayah_number})"
|
| 30 |
+
return f"Error fetching ayah {ayah_number} of surah {surah_number}: {e}"
|
| 31 |
|
| 32 |
@tool
|
| 33 |
def get_current_time_in_timezone(timezone: str) -> str:
|