Introduction
Defining tool schemas and descriptions helps AI agents understand what tools they can use and how to use them correctly.
Jump into concepts and practice - no test required
tool_schema = {
"name": "tool_name",
"description": "What the tool does",
"parameters": {
"param1": "description of param1",
"param2": "description of param2"
}
}tool_schema = {
"name": "calculator",
"description": "Performs basic math operations",
"parameters": {
"operation": "Type of math operation like add or subtract",
"numbers": "List of numbers to calculate"
}
}tool_schema = {
"name": "weather_api",
"description": "Fetches current weather data",
"parameters": {
"location": "City or coordinates for weather data",
"units": "Measurement units like metric or imperial"
}
}def define_tool_schema(name, description, parameters): return { "name": name, "description": description, "parameters": parameters } # Define a tool schema for a text summarizer text_summarizer_schema = define_tool_schema( "text_summarizer", "Summarizes long text into short key points", { "text": "The input text to summarize", "max_length": "Maximum length of the summary" } ) print(text_summarizer_schema)
{"name": "calculator", "description": "Performs math operations", "inputs": {"operation": "string", "x": "number", "y": "number"}}{"name": "translator", "description": "Translates text", "inputs": {"text": "string", "target_lang": "string"}}