"""12 fictional tool schemas (the "real" tools) plus 20 plausible decoys for the 32-tool menu. All schemas are OpenAI-style function definitions, which is what the Qwen chat template's `tools=` argument expects. Nothing here talks to any real service. """ def fn(name, description, properties, required): return { "type": "function", "function": { "name": name, "description": description, "parameters": {"type": "object", "properties": properties, "required": required}, }, } DATE = {"type": "string", "description": "Date in YYYY-MM-DD format."} UNITS = ["km", "mi", "m", "ft", "cm", "in", "kg", "lb", "g", "oz", "c", "f", "l", "gal", "ml"] CURRENCIES = ["USD", "EUR", "GBP", "JPY", "INR", "CHF", "CAD", "AUD"] FILE_TYPES = ["pdf", "docx", "xlsx", "pptx", "png", "jpg", "txt", "md", "csv"] REAL_TOOLS = [ fn("create_calendar_event", "Create an event in the user's calendar.", { "title": {"type": "string", "description": "Short event title."}, "date": DATE, "start_time": {"type": "string", "description": "Start time, 24-hour HH:MM."}, "duration_minutes": {"type": "integer", "description": "Length of the event in minutes."}, "attendees": {"type": "array", "items": {"type": "string"}, "description": "Email addresses to invite."}, "reminder": { "type": "object", "description": "Optional reminder before the event.", "properties": { "minutes_before": {"type": "integer"}, "method": {"type": "string", "enum": ["email", "popup"]}, }, "required": ["minutes_before", "method"], }, "visibility": {"type": "string", "enum": ["private", "public"], "default": "private"}, }, ["title", "date", "start_time", "duration_minutes"]), fn("list_calendar_events", "List events in the user's calendar between two dates (inclusive).", { "date_from": DATE, "date_to": DATE, "calendar": {"type": "string", "enum": ["work", "personal", "all"], "default": "all"}, }, ["date_from", "date_to"]), fn("convert_units", "Convert a physical quantity between units of length, mass, temperature or volume.", { "value": {"type": "number"}, "from_unit": {"type": "string", "enum": UNITS}, "to_unit": {"type": "string", "enum": UNITS}, }, ["value", "from_unit", "to_unit"]), fn("convert_currency", "Convert an amount of money from one currency to another at today's rate.", { "amount": {"type": "number"}, "from_currency": {"type": "string", "enum": CURRENCIES}, "to_currency": {"type": "string", "enum": CURRENCIES}, }, ["amount", "from_currency", "to_currency"]), fn("search_files", "Search the user's files by text query, with optional filters.", { "query": {"type": "string", "description": "Words to search for in file names and contents."}, "filters": { "type": "object", "properties": { "file_types": {"type": "array", "items": {"type": "string", "enum": FILE_TYPES}}, "modified_after": DATE, "folder": {"type": "string", "description": "Folder path, e.g. /Work/Reports"}, }, }, "max_results": {"type": "integer", "default": 10}, }, ["query"]), fn("get_weather", "Get the CURRENT weather conditions for a location (right now only).", { "location": {"type": "string", "description": "City name, optionally with country."}, "units": {"type": "string", "enum": ["metric", "imperial"], "default": "metric"}, }, ["location"]), fn("get_forecast", "Get the daily weather forecast for the next N days for a location.", { "location": {"type": "string", "description": "City name, optionally with country."}, "days": {"type": "integer", "description": "Number of days, 1-7."}, "units": {"type": "string", "enum": ["metric", "imperial"], "default": "metric"}, }, ["location", "days"]), fn("evaluate_math", "Evaluate an arithmetic expression exactly and return the result.", { "expression": {"type": "string", "description": "Expression using + - * / ^ ( ) and numbers."}, "precision": {"type": "integer", "description": "Decimal places to round to.", "default": 2}, }, ["expression"]), fn("add_todo", "Add an item to the user's to-do list.", { "title": {"type": "string"}, "due_date": DATE, "priority": {"type": "string", "enum": ["low", "medium", "high"], "default": "medium"}, "tags": {"type": "array", "items": {"type": "string"}}, }, ["title"]), fn("complete_todo", "Mark an existing to-do item as done, by its numeric id.", { "todo_id": {"type": "integer"}, }, ["todo_id"]), fn("send_email", "Send an email from the user's account.", { "to": {"type": "array", "items": {"type": "string"}, "description": "Recipient email addresses."}, "subject": {"type": "string"}, "body": {"type": "string"}, "cc": {"type": "array", "items": {"type": "string"}}, }, ["to", "subject", "body"]), fn("set_timer", "Start a countdown timer.", { "duration_seconds": {"type": "integer"}, "label": {"type": "string"}, }, ["duration_seconds"]), ] DECOY_TOOLS = [ fn("update_calendar_event", "Change an existing calendar event by id.", { "event_id": {"type": "string"}, "date": DATE, "start_time": {"type": "string"}, "title": {"type": "string"}, }, ["event_id"]), fn("delete_calendar_event", "Delete a calendar event by id.", {"event_id": {"type": "string"}}, ["event_id"]), fn("book_meeting_room", "Reserve a meeting room in the office.", { "room": {"type": "string"}, "date": DATE, "start_time": {"type": "string"}, "duration_minutes": {"type": "integer"}, }, ["room", "date", "start_time", "duration_minutes"]), fn("convert_timezone", "Convert a clock time from one time zone to another.", { "time": {"type": "string"}, "from_tz": {"type": "string"}, "to_tz": {"type": "string"}, }, ["time", "from_tz", "to_tz"]), fn("get_exchange_rate", "Get today's exchange rate between two currencies (no conversion).", { "base": {"type": "string", "enum": CURRENCIES}, "quote": {"type": "string", "enum": CURRENCIES}, }, ["base", "quote"]), fn("get_stock_price", "Get the latest price for a stock ticker.", {"ticker": {"type": "string"}}, ["ticker"]), fn("get_air_quality", "Get the current air-quality index for a location.", { "location": {"type": "string"}, }, ["location"]), fn("get_sunrise_sunset", "Get sunrise and sunset times for a location and date.", { "location": {"type": "string"}, "date": DATE, }, ["location"]), fn("read_file", "Read the contents of a file by exact path.", {"path": {"type": "string"}}, ["path"]), fn("move_file", "Move or rename a file.", { "source": {"type": "string"}, "destination": {"type": "string"}, }, ["source", "destination"]), fn("delete_file", "Delete a file by exact path.", {"path": {"type": "string"}}, ["path"]), fn("list_todos", "List to-do items, optionally filtered.", { "status": {"type": "string", "enum": ["open", "done", "all"]}, "tag": {"type": "string"}, }, []), fn("update_todo", "Edit fields of an existing to-do item.", { "todo_id": {"type": "integer"}, "title": {"type": "string"}, "due_date": DATE, "priority": {"type": "string", "enum": ["low", "medium", "high"]}, }, ["todo_id"]), fn("delete_todo", "Delete a to-do item by id.", {"todo_id": {"type": "integer"}}, ["todo_id"]), fn("draft_email", "Save an email as a draft without sending it.", { "to": {"type": "array", "items": {"type": "string"}}, "subject": {"type": "string"}, "body": {"type": "string"}, }, ["to", "subject", "body"]), fn("search_emails", "Search the user's mailbox.", { "query": {"type": "string"}, "from_address": {"type": "string"}, }, ["query"]), fn("send_sms", "Send a text message to a phone number.", { "phone_number": {"type": "string"}, "message": {"type": "string"}, }, ["phone_number", "message"]), fn("translate_text", "Translate text into another language.", { "text": {"type": "string"}, "target_language": {"type": "string"}, }, ["text", "target_language"]), fn("start_stopwatch", "Start a stopwatch that counts up.", {"label": {"type": "string"}}, []), fn("create_note", "Create a free-form note.", { "title": {"type": "string"}, "content": {"type": "string"}, }, ["title", "content"]), ] REAL_BY_NAME = {t["function"]["name"]: t for t in REAL_TOOLS} ALL_BY_NAME = {t["function"]["name"]: t for t in REAL_TOOLS + DECOY_TOOLS} assert len(REAL_TOOLS) == 12 and len(DECOY_TOOLS) == 20 and len(ALL_BY_NAME) == 32