mgerlitz commited on
Commit
7e7de3a
·
verified ·
1 Parent(s): 5cb40d9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -1
app.py CHANGED
@@ -34,6 +34,28 @@ def get_current_time_in_timezone(timezone: str) -> str:
34
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
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:
@@ -55,7 +77,7 @@ with open("prompts.yaml", 'r') as stream:
55
 
56
  agent = CodeAgent(
57
  model=model,
58
- tools=[final_answer, get_current_time_in_timezone, image_generation_tool], ## add your tools here (don't remove final answer)
59
  max_steps=6,
60
  verbosity_level=1,
61
  grammar=None,
 
34
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
35
 
36
 
37
+ @tool
38
+ def check_prime_number(num: int) -> str:
39
+ """A tool that checks if an integer is a prime number.
40
+ Args:
41
+ num: Integer to check if it is prime.
42
+ """
43
+ if num > 1:
44
+
45
+ # Iterate from 2 to n // 2
46
+ for i in range(2, (num//2)+1):
47
+
48
+ # If num is divisible by any number between
49
+ # 2 and n / 2, it is not prime
50
+ if (num % i) == 0:
51
+ print(num, "is not a prime number")
52
+ break
53
+ else:
54
+ print(num, "is a prime number")
55
+ else:
56
+ print(num, "is not a prime number")
57
+
58
+
59
  final_answer = FinalAnswerTool()
60
 
61
  # 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:
 
77
 
78
  agent = CodeAgent(
79
  model=model,
80
+ tools=[final_answer, get_current_time_in_timezone, image_generation_tool, check_prime_number], ## add your tools here (don't remove final answer)
81
  max_steps=6,
82
  verbosity_level=1,
83
  grammar=None,