Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,6 +8,36 @@ from tools.final_answer import FinalAnswerTool
|
|
| 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
|
|
|
|
| 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 get_ayyahs(word:str,required_instances:int = 3)->list:
|
| 13 |
+
"""
|
| 14 |
+
A tool that get all the occurence of a given word in quran
|
| 15 |
+
Args:
|
| 16 |
+
word: Word to find
|
| 17 |
+
required_instances: Number of instances of the word to return, default is 3.
|
| 18 |
+
"""
|
| 19 |
+
ayats = []
|
| 20 |
+
url = f"http://api.alquran.cloud/v1/search/{word}/all/en.asad"
|
| 21 |
+
try:
|
| 22 |
+
response = requests.get(url)
|
| 23 |
+
data = response.json()
|
| 24 |
+
data = data['data']['matches']
|
| 25 |
+
lenght = min(required_instances,len(data))
|
| 26 |
+
for i in range(lenght):
|
| 27 |
+
ayah = data[i]['text']
|
| 28 |
+
surah_arabic = data[i]['surah']['name']
|
| 29 |
+
surah_english = data[i]['surah']['englishName']
|
| 30 |
+
ayah_no = data[i]['numberInSurah']
|
| 31 |
+
|
| 32 |
+
ayats.append((ayah,surah_arabic,surah_english,ayah_no))
|
| 33 |
+
|
| 34 |
+
return ayats
|
| 35 |
+
|
| 36 |
+
except Exception as e:
|
| 37 |
+
print(f"Problem in get_ayyahs functions: {e}")
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
|
| 41 |
@tool
|
| 42 |
def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
|
| 43 |
#Keep this format for the description / args / args description but feel free to modify the tool
|