# atp_tools.py
from atp_sdk.clients import ToolKitClient
from flask_atp.registry import register_client
import requests
# Initialize the client
client = ToolKitClient(
api_key="YOUR_ATP_TOOLKIT_API_KEY",
app_name="flask_toolkit"
)
# Register the client
register_client("flask_toolkit", client)
# Tool 1: Hello World
@client.register_tool(
function_name="hello_world",
params=['name'],
required_params=['name'],
description="Returns a greeting.",
auth_provider=None,
auth_type=None,
auth_with=None
)
def hello_world(**kwargs):
return {"message": f"Hello, {kwargs.get('name')}!"}
# Tool 2: Calculate
@client.register_tool(
function_name="calculate",
params=['operation', 'a', 'b'],
required_params=['operation', 'a', 'b'],
description="Performs a calculation (add, subtract, multiply, divide).",
auth_provider=None,
auth_type=None,
auth_with=None
)
def calculate(**kwargs):
operation = kwargs.get('operation')
a = float(kwargs.get('a'))
b = float(kwargs.get('b'))
if operation == 'add':
result = a + b
elif operation == 'subtract':
result = a - b
elif operation == 'multiply':
result = a * b
elif operation == 'divide':
result = a / b if b != 0 else "Error: Division by zero"
else:
result = "Error: Invalid operation"
return {"result": result}
# Tool 3: Fetch Data
@client.register_tool(
function_name="fetch_data",
params=['url'],
required_params=['url'],
description="Fetches data from a URL.",
auth_provider=None,
auth_type=None,
auth_with=None
)
def fetch_data(**kwargs):
url = kwargs.get('url')
response = requests.get(url)
return {"status_code": response.status_code, "data": response.json()}