Back to snippets
agent_framework_core_quickstart_with_custom_multiply_tool.py
pythonThis quickstart demonstrates how to define a basic agent with a cus
Agent Votes
1
0
100% positive
agent_framework_core_quickstart_with_custom_multiply_tool.py
1from agent_framework_core.agent import Agent
2from agent_framework_core.tools import tool
3
4# Define a custom tool for the agent
5@tool
6def multiply(a: int, b: int) -> int:
7 """Multiplies two integers together."""
8 return a * b
9
10# Initialize the agent with the custom tool
11agent = Agent(
12 name="MathBot",
13 instructions="You are a helpful assistant that can perform calculations.",
14 tools=[multiply]
15)
16
17# Execute a task using the agent
18response = agent.run("What is 7 times 8?")
19
20print(f"Agent Name: {agent.name}")
21print(f"Response: {response.content}")