Convert a Python function's signature into an OpenAI-compatible tool schema.
The full prompt is available without an account.
Implement to_tool_schema(fn) that returns a dict matching the OpenAI
function-calling format: { "name", "description", "parameters": { ... } }.
Use inspect and typing.get_type_hints to extract parameter names and types.
Map str -> string, int -> integer, float -> number, bool -> boolean.
Read-only Python 3.12 preview. Sign in to edit and execute it.
import inspect
from typing import get_type_hints, Callable
TYPE_MAP = {str: "string", int: "integer", float: "number", bool: "boolean"}
def to_tool_schema(fn: Callable) -> dict:
# TODO: build name, description, and parameters schema
return {}