Docs
OfficialJev Cookbooks
Cookbook: Function Calling
Turn natural language into typed function calls: closed-set arguments become Choice questions, optional ones become Noul questions, and 54 questions ship in one request for a trading assistant.
- Format
- Docs
- Reading time
- 3 min
- Published by
- TypeSafe AI
- Last verified
- Sep 2026
Used inJev for Finance & Fintech
Highlights
- 10 trading functions with 28 fillable closed-set arguments; each command sends 54 questions in one request.
- A stated Noul marks an argument optional, so a no leaves the function's default in place.
- The sample command maps at 0.82 confidence, with the benchmark argument the weakest at 0.78.
Quickstart
python
from dispatch import Dispatcher
assistant = Dispatcher(SPEC, TOOLS, client) # 10 tools -> 54 questions per command
call = assistant("plot rolling correlation between nvda and spy for the past month")
# rolling_correlation(symbol='NVDA', benchmark='SPY', window='1mo')
print(call.tool.probability) # P(this is the right function)
print(call.confidence) # 0.91: the weakest judgement in the call
print(call.arguments["resolution"].omitted) # unstated arg -> function default standsWatch out
Free text, numbers, and dates never get a question and keep the function default, so wire your own parsers for those arguments.
Questions about this entry
Short answers drawn from the linked project or page.
With a stated Noul per argument: a no leaves the function's default in place. Closed-set arguments become Choice questions, and a sample trading command sends 54 questions for 10 functions in one request.
Free text, numbers, and dates. The caveat says those keep the function default, so wire your own parsers for them rather than expecting the dispatcher to fill them.
The type hints already say which arguments come from a fixed list. closed_sets reads a signature and sorts them into three shapes: a choice for a Literal, a set for a list of Literals so any number of them, and a flag for a bool. Across the 10 trading functions that is 28 fillable arguments, and top_movers shows what gets left out: its limit argument is an int, so it keeps its default of 3.
The chosen function with a probability that it is the right one, a confidence that reflects the weakest judgment in the call, and each argument's value plus whether it was omitted so a function default can stand. The rolling-correlation sample maps at 0.82 confidence with the benchmark argument the weakest at 0.78.
A spec you add, held in spec.json: a question per argument, a line per option, a description per function and one more question that picks between the functions. The Literal type gives you the strings but not the intent, so the spec is where you say that a user typing this quarter means the three-month window. An LLM can write that spec for you from the signatures, and the functions themselves are left alone.
A sentence in and a typed call out: plot rolling correlation between nvda and spy for the past month becomes rolling_correlation with symbol NVDA, benchmark SPY and window 1mo at 0.91 confidence, what tickers do you have becomes a bare list_symbols() at 1.00, and show me apple daily with volume maps to a plot_price call at 0.75.
pip install ipython polars matplotlib numpy 'cooksafe>=0.2.0,<0.3.0' and set TYPESAFE_API_KEY. Two modules sit beside the notebook: trader.py holds the 10 functions, running over 156,780 one-minute bars, plus a client that reads cached answers so a re-render replays the numbers, and dispatch.py reads a signature and a spec to make the call. The model is jev-1.12.
Reactions & coverage
Posts, threads, and videos about this entry from around the web.
X: Tool calling as classify plus action, back to twelve-factor agents
X: A chat bot with no LLM
From the Jev guides
Original write-ups on what this entry is for.
From the Jev AI model community
Posts from builders shipping with Jev right now.