Update app.py
Browse filesadded new tool function named convert_dog_age_to_human_age
app.py
CHANGED
|
@@ -8,21 +8,15 @@ from tools.final_answer import FinalAnswerTool
|
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
| 10 |
@tool
|
| 11 |
-
def
|
| 12 |
-
"""
|
| 13 |
-
Returns the sum of two numbers.
|
| 14 |
-
|
| 15 |
Args:
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
Returns:
|
| 20 |
-
int: The sum of the two numbers provided.
|
| 21 |
"""
|
|
|
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
return result_sum;
|
| 26 |
|
| 27 |
@tool
|
| 28 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
@@ -41,10 +35,14 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 41 |
|
| 42 |
|
| 43 |
final_answer = FinalAnswerTool()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
model = HfApiModel(
|
| 45 |
max_tokens=2096,
|
| 46 |
temperature=0.5,
|
| 47 |
-
model_id='
|
| 48 |
custom_role_conversions=None,
|
| 49 |
)
|
| 50 |
|
|
@@ -57,7 +55,10 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 57 |
|
| 58 |
agent = CodeAgent(
|
| 59 |
model=model,
|
| 60 |
-
tools=[
|
|
|
|
|
|
|
|
|
|
| 61 |
max_steps=6,
|
| 62 |
verbosity_level=1,
|
| 63 |
grammar=None,
|
|
|
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
| 10 |
@tool
|
| 11 |
+
def convert_dog_age_to_human_age(name_of_pet: str, dog_age: int) -> int:
|
| 12 |
+
"""A tool that returns the age of a dog in human age
|
|
|
|
|
|
|
| 13 |
Args:
|
| 14 |
+
name_of_pet: Name of pet
|
| 15 |
+
dog_age: Age of dog
|
|
|
|
|
|
|
|
|
|
| 16 |
"""
|
| 17 |
+
human_age = dog_age * 7;
|
| 18 |
|
| 19 |
+
return f"{name_of_pet}'s age in human years is '{human_age}."
|
|
|
|
|
|
|
| 20 |
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 35 |
|
| 36 |
|
| 37 |
final_answer = FinalAnswerTool()
|
| 38 |
+
|
| 39 |
+
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|
| 40 |
+
# model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
|
| 41 |
+
|
| 42 |
model = HfApiModel(
|
| 43 |
max_tokens=2096,
|
| 44 |
temperature=0.5,
|
| 45 |
+
model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
|
| 46 |
custom_role_conversions=None,
|
| 47 |
)
|
| 48 |
|
|
|
|
| 55 |
|
| 56 |
agent = CodeAgent(
|
| 57 |
model=model,
|
| 58 |
+
tools=[
|
| 59 |
+
final_answer,
|
| 60 |
+
convert_dog_age_to_human_age
|
| 61 |
+
],
|
| 62 |
max_steps=6,
|
| 63 |
verbosity_level=1,
|
| 64 |
grammar=None,
|