Skip to content

Feat: use _UNSET sentinel to exclude unset UiPathChat params from payload#70

Merged
cosminacho merged 3 commits into
mainfrom
feat/uipath-chat-unset-sentinel
Apr 22, 2026
Merged

Feat: use _UNSET sentinel to exclude unset UiPathChat params from payload#70
cosminacho merged 3 commits into
mainfrom
feat/uipath-chat-unset-sentinel

Conversation

@cosminacho

Copy link
Copy Markdown
Collaborator

Summary

UiPathChat parameter fields (temperature, max_tokens, reasoning, thinking, etc.) previously defaulted to None, and _default_params used v is not None to decide what to send to the normalized API. That made "caller did not pass anything" indistinguishable from "caller explicitly passed None" — both were dropped from the request payload.

This PR introduces an _UnsetType singleton (_UNSET) that fields now default to. _default_params filters on isinstance(v, _UnsetType) instead of v is None. Pattern mirrors the existing _UNSET: Any = object() sentinel already used in src/uipath/llm_client/httpx_client.py for similar "not provided vs. explicit override" handling, promoted to a proper typed class so pydantic-validated field defaults work.

Behavior change (breaking for callers relying on None=omit)

  • UiPathChat(temperature=None) now sends "temperature": null to the API. Previously it was dropped.
  • Unset fields (UiPathChat() without temperature=) continue to be omitted — no change there.
  • Also removes the old "stop": self.stop or None coercion so explicit stop=[] / stop="" likewise flow through.

Callers that used None as shorthand for "omit" should just stop passing the argument.

Which package

  • Langchain only (uipath-langchain-client 1.9.6 → 1.9.7). Core is not touched.

Test plan

  • ruff check
  • ruff format --check
  • pyright
  • pytest tests — 1522 passed, 736 skipped, 9 xpassed

🤖 Generated with Claude Code

…load

`UiPathChat` parameter fields now default to an internal `_UNSET`
singleton instead of `None`, and `_default_params` filters on the
sentinel rather than on `None`.

Behavior change: passing an explicit `None` (e.g. `UiPathChat(
temperature=None)`) now forwards `null` to the normalized API instead
of being silently dropped. Unset fields continue to be omitted.
Callers relying on `None` as shorthand for "omit" should stop passing
the argument.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…load

Fields default to `_UNSET = object()` instead of `None`. `_default_params`
filters with `v is not _UNSET` — unset params are omitted, explicit `None`
passes through to the API as null.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Replace the _UNSET sentinel approach with pydantic's built-in
model_fields_set. Fields keep plain `int | None = None` defaults;
_default_params includes only fields that were explicitly set by
the caller. Explicit None passes through to the API as null.

No sentinel class, no type: ignore, no extra model_config needed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@cosminacho cosminacho merged commit cfb4fea into main Apr 22, 2026
8 checks passed
@cosminacho cosminacho deleted the feat/uipath-chat-unset-sentinel branch April 22, 2026 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant