Update app.py
Browse files
app.py
CHANGED
|
@@ -18,6 +18,44 @@ def my_cutom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
|
|
| 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.
|
|
@@ -51,7 +89,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 51 |
|
| 52 |
agent = CodeAgent(
|
| 53 |
model=model,
|
| 54 |
-
tools=[final_answer], ## add your tools here (don't remove final answer)
|
| 55 |
max_steps=6,
|
| 56 |
verbosity_level=1,
|
| 57 |
grammar=None,
|
|
|
|
| 18 |
"""
|
| 19 |
return "What magic will you build ?"
|
| 20 |
|
| 21 |
+
@tool
|
| 22 |
+
def get_sura(sura_number: int) -> str:
|
| 23 |
+
"""A tool that gets the text of a sura based on its sura number
|
| 24 |
+
Args:
|
| 25 |
+
sura_number: The sura number of the sura.
|
| 26 |
+
"""
|
| 27 |
+
url = f"http://quran-challenge.com/app/php/getverses.php?sura_number={sura_number}"
|
| 28 |
+
response = requests.get(url)
|
| 29 |
+
|
| 30 |
+
if response.status_code == 200:
|
| 31 |
+
data = response.json()
|
| 32 |
+
result = ""
|
| 33 |
+
|
| 34 |
+
for verse in data:
|
| 35 |
+
nr = verse['nr']
|
| 36 |
+
tanzil_text = verse['tanzil_text']
|
| 37 |
+
result += f"{nr}: {tanzil_text}\n"
|
| 38 |
+
|
| 39 |
+
return f"The text of the sura is:\n {result}"
|
| 40 |
+
else:
|
| 41 |
+
return "Error: Could not fetch the sura data."
|
| 42 |
+
|
| 43 |
+
@tool
|
| 44 |
+
def calculate_expenses(sallery: int) -> str:
|
| 45 |
+
"""A tool that calculate the expenses of a given sallery.
|
| 46 |
+
Args:
|
| 47 |
+
sallery: The given sallery.
|
| 48 |
+
"""
|
| 49 |
+
return f"the expenses of the sallery {sallery} are: {sallery * 0.82 + (sallery * (0.03))} CHF."
|
| 50 |
+
|
| 51 |
+
@tool
|
| 52 |
+
def encode_text(text: str) -> str:
|
| 53 |
+
"""A tool that encodes a given text.
|
| 54 |
+
Args:
|
| 55 |
+
text: The text to be encoded.
|
| 56 |
+
"""
|
| 57 |
+
return ''.join(chr(ord(char) + 2) for char in text)
|
| 58 |
+
|
| 59 |
@tool
|
| 60 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 61 |
"""A tool that fetches the current local time in a specified timezone.
|
|
|
|
| 89 |
|
| 90 |
agent = CodeAgent(
|
| 91 |
model=model,
|
| 92 |
+
tools=[final_answer, encode_text, get_sura, calculate_expenses], ## add your tools here (don't remove final answer)
|
| 93 |
max_steps=6,
|
| 94 |
verbosity_level=1,
|
| 95 |
grammar=None,
|