From 7dd089445c7d5269f79ca2131b8529889984bb30 Mon Sep 17 00:00:00 2001 From: Georg Grab Date: Sun, 10 May 2026 12:51:00 +0200 Subject: [PATCH] Translate user-facing thinking_metric to wire thinking_effort_metric MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The merged PRs renamed in different directions: - tabpfn-server (#852): server's FitRequest field is `thinking_effort_metric` - tabpfn-client (#270): client's user-facing kwarg is `thinking_metric` Result: any fit from `tabpfn-client@main` against `api.priorlabs.ai` 422s with `extra_forbidden` on `thinking_metric` — including plain v3/v2.5 fits, because the client always serialises the field as `null` even when thinking is off. Keeps the public API as `thinking_metric` (TabPFNClassifier/Regressor kwarg, `validate_thinking_mode`, the instance attribute), and only renames the FitRequest wire field + the call site that builds the request to `thinking_effort_metric` so the body matches the server's schema. Existing user code does not need to change. --- src/tabpfn_client/api_models.py | 2 +- src/tabpfn_client/client.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/tabpfn_client/api_models.py b/src/tabpfn_client/api_models.py index cf1a5a8..941e0d8 100644 --- a/src/tabpfn_client/api_models.py +++ b/src/tabpfn_client/api_models.py @@ -108,7 +108,7 @@ class FitRequest(BaseModel): # Budget for the fit (seconds). Only consulted when `thinking_effort` is set. thinking_timeout_s: Optional[float] = None # Optimization metric for the fit. Only consulted when `thinking_effort` is set. - thinking_metric: Optional[str] = None + thinking_effort_metric: Optional[str] = None class FitResponse(BaseModel): diff --git a/src/tabpfn_client/client.py b/src/tabpfn_client/client.py index 8ab3a4c..170ed4c 100644 --- a/src/tabpfn_client/client.py +++ b/src/tabpfn_client/client.py @@ -407,6 +407,8 @@ def fit( # The client-side `thinking_*` knobs forward 1:1 to the server's # top-level FitRequest fields. When the user enabled thinking via # `thinking_mode=True` without picking a level, default to "medium". + # The user-facing kwarg is `thinking_metric`; on the wire it is sent + # as `thinking_effort_metric` (matching the server's FitRequest schema). if thinking_enabled and tabpfn_config: thinking_effort = tabpfn_config.get("thinking_effort") or "medium" thinking_timeout_s = tabpfn_config.get("thinking_timeout_s") @@ -444,7 +446,7 @@ def fit( tabpfn_config=server_tabpfn_config, thinking_effort=thinking_effort, thinking_timeout_s=thinking_timeout_s, - thinking_metric=thinking_metric, + thinking_effort_metric=thinking_metric, ), timeout=client_options.timeout, headers=client_options.headers,