tool functions and pytest

This commit is contained in:
2025-01-01 18:20:50 +01:00
parent 823f13ab51
commit fd7e3d5235
10 changed files with 406 additions and 108 deletions

35
tool_functions.py Normal file
View File

@@ -0,0 +1,35 @@
import random
import datetime
from tool_helper import tool
@tool
def current_time():
"""Get the current local date and time as a string."""
return datetime.datetime.now().strftime("%Y-%m-%d %H:%M")
# @tool
# def random_float():
# """Generate a random float from 0..1."""
# return str(random.random())
@tool
def random_float(a: float=0.0, b: float=1.0):
"""Generate a random float in range [a, b], including both end points. Optional pass no parameter and range 0..1 will be used.
Args:
a: minimum possible value
b: maximum possible value"""
return str(random.randint(a, b))
@tool
def random_int(a: int, b: int):
"""Generate a random integer in range [a, b], including both end points.
Args:
a: minimum possible value
b: maximum possible value"""
return str(random.randint(a, b))
def register_dummy():
pass # dummy function to run and be sure the decorators have run