Tools is broken
This commit is contained in:
@@ -583,4 +583,16 @@ def generate_mikrotik_CPE_script(**kwargs: Any) -> Dict[str, Any]:
|
||||
return {"error": f"An unexpected internal error occurred while generating the script: {str(e)}"} # Return generic error
|
||||
|
||||
# --- End Tool Implementation ---
|
||||
|
||||
# --------------------------------------------------
|
||||
# Tool Entrypoint (required by tool_loader)
|
||||
# --------------------------------------------------
|
||||
|
||||
def run(**kwargs):
|
||||
"""
|
||||
Tool entrypoint required by the bot runtime.
|
||||
This must exist so the LLM can execute the tool.
|
||||
"""
|
||||
return generate_mikrotik_CPE_script(**kwargs)
|
||||
|
||||
# --- END OF FILE mtscripter.py ---
|
||||
@@ -128,3 +128,11 @@ def get_imail_password(username, domain):
|
||||
|
||||
except Exception as e:
|
||||
return {"status": "error", "message": f"Database error: {str(e)}"}
|
||||
|
||||
def run(**kwargs):
|
||||
"""
|
||||
Tool entrypoint required by the bot runtime.
|
||||
This must exist so the LLM can execute the tool.
|
||||
"""
|
||||
return get_imail_password(**kwargs)
|
||||
|
||||
|
||||
47
tools/simple_calculator.py
Normal file
47
tools/simple_calculator.py
Normal file
@@ -0,0 +1,47 @@
|
||||
TOOL_DEFINITION = {
|
||||
"name": "calculator",
|
||||
"description": "Performs basic math calculations. Can add, subtract, multiply, or divide two numbers.",
|
||||
"input_schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"operation": {
|
||||
"type": "string",
|
||||
"enum": ["add", "subtract", "multiply", "divide"],
|
||||
"description": "The math operation to perform"
|
||||
},
|
||||
"a": {
|
||||
"type": "number",
|
||||
"description": "First number"
|
||||
},
|
||||
"b": {
|
||||
"type": "number",
|
||||
"description": "Second number"
|
||||
}
|
||||
},
|
||||
"required": ["operation", "a", "b"]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def run(operation: str, a: float, b: float) -> dict:
|
||||
"""
|
||||
Execute the calculation.
|
||||
"""
|
||||
operations = {
|
||||
"add": lambda x, y: x + y,
|
||||
"subtract": lambda x, y: x - y,
|
||||
"multiply": lambda x, y: x * y,
|
||||
"divide": lambda x, y: x / y if y != 0 else "Error: Division by zero"
|
||||
}
|
||||
|
||||
if operation not in operations:
|
||||
return {"error": f"Unknown operation: {operation}"}
|
||||
|
||||
result = operations[operation](a, b)
|
||||
|
||||
return {
|
||||
"operation": operation,
|
||||
"a": a,
|
||||
"b": b,
|
||||
"result": result
|
||||
}
|
||||
Reference in New Issue
Block a user