mirror of
https://github.com/microsoft/autogen.git
synced 2025-07-14 12:31:28 +00:00

This PR does the following: - Fix warning messages in AGS on launch. - Improve Cli message to include app URL on startup from command line - Minor improvements default gallery generator. (add more default tools) - Improve new session behaviour. ## Related issue number Closes #5097 ## Checks
29 lines
778 B
Python
29 lines
778 B
Python
from autogen_core.tools import FunctionTool
|
|
|
|
|
|
def calculator(a: float, b: float, operator: str) -> str:
|
|
try:
|
|
if operator == "+":
|
|
return str(a + b)
|
|
elif operator == "-":
|
|
return str(a - b)
|
|
elif operator == "*":
|
|
return str(a * b)
|
|
elif operator == "/":
|
|
if b == 0:
|
|
return "Error: Division by zero"
|
|
return str(a / b)
|
|
else:
|
|
return "Error: Invalid operator. Please use +, -, *, or /"
|
|
except Exception as e:
|
|
return f"Error: {str(e)}"
|
|
|
|
|
|
# Create calculator tool
|
|
calculator_tool = FunctionTool(
|
|
name="calculator",
|
|
description="A simple calculator that performs basic arithmetic operations",
|
|
func=calculator,
|
|
global_imports=[],
|
|
)
|