Which date is earlier?
Open in playground →A date comparison models often get backwards. With thinking on auto, the model decides it needs to think, and the earlier date comes back as one of the two strings, with a probability for each.
Challenges
- Models tend to read
xx/xx/yyyyas US month-first, so07/06/2026looks like July 6 and they pickJune 8, 2026. Stating the format in the context is often not enough. - With
"thinking": "auto", the field first gets a level of thinking for this call; this one gets some (thinking_effortreports it). The model then reads07/06/2026as day 7, month 6, puts both dates in the same form and compares them before it answers, and its reasoning comes back with the result. return_probabilitiesworks on enum and boolean fields, so the answer is astringenum of the two dates. It is always one of them, and each comes back with a probability.
import os
from typellm import TypeLLMClient
client = TypeLLMClient(api_key=os.environ["TYPELLM_API_KEY"])
response = client.generate(
context="Two dates: June 8, 2026 and 07/06/2026. Dates written as xx/xx/yyyy are DD/MM/YYYY.",
questions={
"earlier": {
"type": "string",
"enum": [
"June 8, 2026",
"07/06/2026"
],
"instructions": "Which date is earlier?",
"thinking": "auto",
"return_probabilities": True
}
},
)
print(response)Generation(
result={
'earlier': {
'value': '07/06/2026',
'probabilities': {
'June 8, 2026': 0,
'07/06/2026': 1,
},
},
},
thinking={
'earlier': 'We need answer user\'s simple question. Need produce final JSON. Need determine earlier date. Dates: June 8, 2026 and 07/06/2026 where xx/xx/yyyy is DD/MM/YYYY. 07/06/2026 = 7 June 2026. June 8 = 8 June 2026. Earlier is 7 June, label B. Output {"earlier": "B"}.',
},
usage=Usage(input_tokens=95, thinking_tokens=105),
thinking_effort={
'earlier': 'low',
},
)