Skip to content

Commit 5cb6039

Browse files
feat: make converse as default api flavor for bedrock
1 parent ff7262e commit 5cb6039

4 files changed

Lines changed: 99 additions & 20 deletions

File tree

packages/uipath_langchain_client/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
All notable changes to `uipath_langchain_client` will be documented in this file.
44

5+
## [1.12.0] - 2026-05-21
6+
7+
### Changed
8+
- `get_chat_model` routes the AWSBEDROCK branch purely by `api_flavor`: `ApiFlavor.INVOKE` selects `UiPathChatBedrock`, while `None` or `ApiFlavor.CONVERSE` select `UiPathChatBedrockConverse`. Model family no longer influences the choice.
9+
10+
### Removed
11+
- The AWSBEDROCK branch no longer auto-selects `UiPathChatAnthropicBedrock` for `ANTHROPIC_CLAUDE` models. Callers who want that class can pass it via the `custom_class` kwarg.
12+
513
## [1.11.3] - 2026-05-21
614

715
### Fixed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
__title__ = "UiPath LangChain Client"
22
__description__ = "A Python client for interacting with UiPath's LLM services via LangChain."
3-
__version__ = "1.11.3"
3+
__version__ = "1.12.0"

packages/uipath_langchain_client/src/uipath_langchain_client/factory.py

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
from typing import Any
2424

25-
from uipath.llm_client.utils.model_family import is_anthropic_model_name
2625
from uipath_langchain_client.base_client import (
2726
UiPathBaseChatModel,
2827
UiPathBaseEmbeddings,
@@ -65,9 +64,8 @@ def get_chat_model(
6564
If not provided, auto-detected from the model discovery endpoint.
6665
api_flavor: Vendor-specific API flavor to use. Effects:
6766
- OpenAI: ApiFlavor.RESPONSES sets use_responses_api=True.
68-
- Bedrock Claude: Default uses UiPathChatAnthropicBedrock.
69-
ApiFlavor.CONVERSE uses UiPathChatBedrockConverse,
70-
ApiFlavor.INVOKE uses UiPathChatBedrock.
67+
- Bedrock: ApiFlavor.INVOKE uses UiPathChatBedrock; otherwise
68+
(None or ApiFlavor.CONVERSE) uses UiPathChatBedrockConverse.
7169
custom_class: A custom class to use for instantiating the chat model instead of the
7270
auto-detected one. Must be a subclass of UiPathBaseChatModel. When provided,
7371
the factory skips vendor detection and uses this class directly.
@@ -190,21 +188,6 @@ def get_chat_model(
190188
**model_kwargs,
191189
)
192190
case VendorType.AWSBEDROCK:
193-
if (
194-
model_family == ModelFamily.ANTHROPIC_CLAUDE and api_flavor != ApiFlavor.CONVERSE
195-
) or (api_flavor == ApiFlavor.INVOKE and is_anthropic_model_name(model_name)):
196-
from uipath_langchain_client.clients.bedrock.chat_models import (
197-
UiPathChatAnthropicBedrock,
198-
)
199-
200-
return UiPathChatAnthropicBedrock(
201-
model=model_name,
202-
settings=client_settings,
203-
byo_connection_id=byo_connection_id,
204-
model_details=model_details,
205-
**model_kwargs,
206-
)
207-
208191
if api_flavor == ApiFlavor.INVOKE:
209192
from uipath_langchain_client.clients.bedrock.chat_models import (
210193
UiPathChatBedrock,

tests/langchain/features/test_factory_function.py

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,94 @@ def test_openai_chat_respects_discovered_byom_chat_completions(
130130
assert captured["api_flavor"] == ApiFlavor.CHAT_COMPLETIONS
131131

132132

133+
class TestFactoryBedrockApiFlavorRouting:
134+
"""The AWSBEDROCK branch routes purely on ``api_flavor``:
135+
136+
- ``ApiFlavor.INVOKE`` -> ``UiPathChatBedrock``
137+
- ``ApiFlavor.CONVERSE`` or ``None`` -> ``UiPathChatBedrockConverse``
138+
139+
Model family (e.g. ANTHROPIC_CLAUDE) no longer influences the choice.
140+
"""
141+
142+
def _patch_bedrock_classes(self, monkeypatch: pytest.MonkeyPatch) -> dict:
143+
"""Replace the three bedrock chat classes with sentinels and record which one was built."""
144+
chosen: dict = {}
145+
146+
def _make_stub(name: str):
147+
class _Stub:
148+
def __init__(self, **kwargs):
149+
chosen["class"] = name
150+
chosen["kwargs"] = kwargs
151+
152+
return _Stub
153+
154+
for name in (
155+
"UiPathChatBedrockConverse",
156+
"UiPathChatBedrock",
157+
"UiPathChatAnthropicBedrock",
158+
):
159+
monkeypatch.setattr(
160+
f"uipath_langchain_client.clients.bedrock.chat_models.{name}",
161+
_make_stub(name),
162+
)
163+
return chosen
164+
165+
def _settings_with_model_info(self, model_info: dict):
166+
settings = MagicMock()
167+
settings.get_model_info.return_value = model_info
168+
return settings
169+
170+
def test_no_api_flavor_uses_bedrock_converse(self, monkeypatch: pytest.MonkeyPatch):
171+
chosen = self._patch_bedrock_classes(monkeypatch)
172+
settings = self._settings_with_model_info(
173+
{
174+
"modelName": "anthropic.claude-3-5-sonnet-20240620-v1:0",
175+
"vendor": "AwsBedrock",
176+
"apiFlavor": None,
177+
"modelFamily": None,
178+
}
179+
)
180+
get_chat_model(
181+
model_name="anthropic.claude-3-5-sonnet-20240620-v1:0",
182+
client_settings=settings,
183+
)
184+
assert chosen["class"] == "UiPathChatBedrockConverse"
185+
186+
def test_converse_api_flavor_uses_bedrock_converse(self, monkeypatch: pytest.MonkeyPatch):
187+
chosen = self._patch_bedrock_classes(monkeypatch)
188+
settings = self._settings_with_model_info(
189+
{
190+
"modelName": "anthropic.claude-3-5-sonnet-20240620-v1:0",
191+
"vendor": "AwsBedrock",
192+
"apiFlavor": None,
193+
"modelFamily": None,
194+
}
195+
)
196+
get_chat_model(
197+
model_name="anthropic.claude-3-5-sonnet-20240620-v1:0",
198+
client_settings=settings,
199+
api_flavor=ApiFlavor.CONVERSE,
200+
)
201+
assert chosen["class"] == "UiPathChatBedrockConverse"
202+
203+
def test_invoke_api_flavor_uses_bedrock_invoke(self, monkeypatch: pytest.MonkeyPatch):
204+
chosen = self._patch_bedrock_classes(monkeypatch)
205+
settings = self._settings_with_model_info(
206+
{
207+
"modelName": "amazon.titan-text-express-v1",
208+
"vendor": "AwsBedrock",
209+
"apiFlavor": None,
210+
"modelFamily": None,
211+
}
212+
)
213+
get_chat_model(
214+
model_name="amazon.titan-text-express-v1",
215+
client_settings=settings,
216+
api_flavor=ApiFlavor.INVOKE,
217+
)
218+
assert chosen["class"] == "UiPathChatBedrock"
219+
220+
133221
class TestFactoryAgentHubConfig:
134222
"""The ``agenthub_config`` factory kwarg overrides ``client_settings.agenthub_config``
135223
via ``model_copy`` so the caller's instance is not mutated."""

0 commit comments

Comments
 (0)