feat: per-vendor model_name defaults on new chat clients (parity with legacy)#809
Open
cosminacho wants to merge 1 commit intomainfrom
Open
feat: per-vendor model_name defaults on new chat clients (parity with legacy)#809cosminacho wants to merge 1 commit intomainfrom
cosminacho wants to merge 1 commit intomainfrom
Conversation
Ports the legacy model_name defaults from the pre-migration UiPathRequestMixin / BedrockModels / GeminiModels over to the new uipath_langchain_client-backed re-exports so callers can construct UiPathChat(), UiPathChatBedrock(), UiPathChatVertex() etc. with no args. Defaults per vendor: - OpenAI / Azure (UiPathChat, UiPathAzureChatOpenAI, UiPathChatOpenAI): UIPATH_MODEL_NAME env var, fallback gpt-4.1-mini-2025-04-14. - Bedrock (UiPathChatBedrock, UiPathChatAnthropicBedrock, UiPathChatBedrockConverse): anthropic.claude-haiku-4-5-20251001-v1:0. - Vertex (UiPathChatGoogleGenerativeAI, UiPathChatVertex): gemini-2.5-flash. Classes without a legacy equivalent (UiPathChatAnthropic, UiPathChatAnthropicVertex, UiPathChatFireworks) keep model= required. Implementation: defaults are attached inline in the per-vendor re-export files (chat/openai.py, chat/bedrock.py, chat/vertex.py, chat/models.py). For most classes this is a one-liner FieldInfo mutation (cls.model_fields["model_name"].default_factory = factory; cls.model_rebuild(force=True)) which pydantic V2 scopes per class. UiPathChatBedrockConverse is the one class where the field-default path does not suffice — its upstream ChatBedrockConverse.set_disable_streaming before-validator reads model / model_id from the raw input dict before field defaults fire — so it gets a thin subclass with our own @model_validator(mode="before") that injects the default into values. Version bump 0.10.5 -> 0.10.6. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
d3e73bc to
98ecefa
Compare
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
The legacy chat classes had per-vendor
model_namedefaults so callers could instantiateUiPathChat()orUiPathChatBedrock()with no args. The new classes re-exported fromuipath_langchain.chat(backed byuipath_langchain_client) don't —model=is a required pydantic field. This PR restores parity where a legacy default existed.Per-vendor defaults (verified against the git history of the legacy classes)
UiPathChat,UiPathAzureChatOpenAI,UiPathChatOpenAIUIPATH_MODEL_NAME→gpt-4.1-mini-2025-04-14default_factoryUiPathChatGoogleGenerativeAI,UiPathChatVertexgemini-2.5-flashdefault_factoryUiPathChatBedrock,UiPathChatAnthropicBedrockanthropic.claude-haiku-4-5-20251001-v1:0default_factoryUiPathChatBedrockConverseanthropic.claude-haiku-4-5-20251001-v1:0model_validator(mode="before")Classes with NO default (
model=stays required)UiPathChatAnthropicUiPathChatAnthropicVertexUiPathChatFireworksOnly Azure-backed classes ever honored
UIPATH_MODEL_NAME; Bedrock and Vertex legacy defaults were hardcoded. Verified in commit634d9fe feat: add chat models.Approach
Each existing vendor re-export file is where:
uipath_langchain_clientclass is first importedmodel_namedefault is attached inlineFor classes where it works, the default is attached via pydantic
FieldInfomutation directly on the upstream class:cls.model_fields["model_name"].default_factory = factory; cls.model_rebuild(force=True). Pydantic V2 gives each class its ownFieldInfoinstance at class creation, so the mutation is scoped to exactly that class and doesn't leak to siblings or parents inuipath_langchain_client.UiPathChatBedrockConversegets a thin subclass with a@model_validator(mode="before")because its upstreamChatBedrockConverse.set_disable_streamingreadsmodel/model_idfrom the raw input dict before field defaults fire.Properties preserved
model=...kwarg still wins over the default.UiPathChatBedrockConverse, the re-export is a subclass —issubclasscheck still holds.UiPathChatdoesn't load Bedrock/Vertex code.Bookkeeping
pyproject.toml:0.10.5→0.10.6uv.lockrefreshedTest plan
uipath_langchain.chatAPI only. For each of the 8 defaulted classes: constructcls()with no model kwarg and assert.model_name. For the 3 non-defaulted classes: assertValidationErroris raised. Plus env-var behavior, identity/alias, and subclass-relationship assertions. All pass.uv run pytest tests/chat/— 192 passeduv run mypy src/— cleanjust lint— cleanGenerated with Claude Code