tool functions and pytest
This commit is contained in:
35
tool_functions.py
Normal file
35
tool_functions.py
Normal 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
|
Reference in New Issue
Block a user