A minimal Python demo showing OpenAI function/tool calling with exactly two tools:
c_to_f— convert Celsius to Fahrenheitf_to_c— convert Fahrenheit to Celsius
- Python 3.10+
cp .env.example .envand put your key inOPENAI_API_KEY=...- Install:
pip install -r requirements.txt
- python -m tool_calling.chat
-
How to define tool schema (name + JSON params)
-
Letting the model choose which tool to call
-
Executing the Python tool and feeding results back to the model
-
convert 100F to C
-
what is 37 celsius in fahrenheit?
-
can you convert -10 C to F?
-
i have 212 f — what's that in c?