Feat: use _UNSET sentinel to exclude unset UiPathChat params from payload#70
Merged
Conversation
…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>
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
UiPathChatparameter fields (temperature,max_tokens,reasoning,thinking, etc.) previously defaulted toNone, and_default_paramsusedv is not Noneto decide what to send to the normalized API. That made "caller did not pass anything" indistinguishable from "caller explicitly passedNone" — both were dropped from the request payload.This PR introduces an
_UnsetTypesingleton (_UNSET) that fields now default to._default_paramsfilters onisinstance(v, _UnsetType)instead ofv is None. Pattern mirrors the existing_UNSET: Any = object()sentinel already used insrc/uipath/llm_client/httpx_client.pyfor 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": nullto the API. Previously it was dropped.UiPathChat()withouttemperature=) continue to be omitted — no change there."stop": self.stop or Nonecoercion so explicitstop=[]/stop=""likewise flow through.Callers that used
Noneas shorthand for "omit" should just stop passing the argument.Which package
uipath-langchain-client1.9.6 → 1.9.7). Core is not touched.Test plan
ruff checkruff format --checkpyrightpytest tests— 1522 passed, 736 skipped, 9 xpassed🤖 Generated with Claude Code