Spaces:
Sleeping
Sleeping
Update app.py
Browse filesPascal's sum tool added.
app.py
CHANGED
|
@@ -46,7 +46,20 @@ model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may
|
|
| 46 |
custom_role_conversions=None,
|
| 47 |
)
|
| 48 |
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
# Import tool from Hub
|
| 51 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 52 |
|
|
@@ -55,7 +68,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 55 |
|
| 56 |
agent = CodeAgent(
|
| 57 |
model=model,
|
| 58 |
-
tools=[final_answer], ## add your tools here (don't remove final answer)
|
| 59 |
max_steps=6,
|
| 60 |
verbosity_level=1,
|
| 61 |
grammar=None,
|
|
|
|
| 46 |
custom_role_conversions=None,
|
| 47 |
)
|
| 48 |
|
| 49 |
+
# My tool
|
| 50 |
+
@tool
|
| 51 |
+
def sum_to_num(num:int) -> int:
|
| 52 |
+
"""A tool that calculates the sum of all natural numbers up to the number passed as parameter.
|
| 53 |
+
Args:
|
| 54 |
+
num: a positive integer number.
|
| 55 |
+
"""
|
| 56 |
+
if isinstance(num, int):
|
| 57 |
+
if num > 1:
|
| 58 |
+
return num*(num-1)/2
|
| 59 |
+
else:
|
| 60 |
+
raise Value("Please insert a value greater than 1.")
|
| 61 |
+
else:
|
| 62 |
+
raise TypeError("Only natural numbers greater than 1 are accepted.")
|
| 63 |
# Import tool from Hub
|
| 64 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 65 |
|
|
|
|
| 68 |
|
| 69 |
agent = CodeAgent(
|
| 70 |
model=model,
|
| 71 |
+
tools=[final_answer, image_generation_tool, sum_to_num], ## add your tools here (don't remove final answer)
|
| 72 |
max_steps=6,
|
| 73 |
verbosity_level=1,
|
| 74 |
grammar=None,
|