Skip to content

Commit 5bca221

Browse files
cosminachoclaude
andauthored
feat(langchain): route INVOKE + AnthropicClaude to UiPathChatAnthropicBedrock (#87)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 3aa36ea commit 5bca221

4 files changed

Lines changed: 65 additions & 7 deletions

File tree

packages/uipath_langchain_client/CHANGELOG.md

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

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

5+
## [1.12.1] - 2026-05-22
6+
7+
### Changed
8+
- `get_chat_model` once again routes to `UiPathChatAnthropicBedrock` when `api_flavor == ApiFlavor.INVOKE` and discovery reports `modelFamily == AnthropicClaude`. Other INVOKE families still use `UiPathChatBedrock`, and `None`/`CONVERSE` continue to use `UiPathChatBedrockConverse`.
9+
510
## [1.12.0] - 2026-05-21
611

712
### Changed
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.12.0"
3+
__version__ = "1.12.1"

packages/uipath_langchain_client/src/uipath_langchain_client/factory.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,10 @@ def get_chat_model(
6464
If not provided, auto-detected from the model discovery endpoint.
6565
api_flavor: Vendor-specific API flavor to use. Effects:
6666
- OpenAI: ApiFlavor.RESPONSES sets use_responses_api=True.
67-
- Bedrock: ApiFlavor.INVOKE uses UiPathChatBedrock; otherwise
68-
(None or ApiFlavor.CONVERSE) uses UiPathChatBedrockConverse.
67+
- Bedrock: ApiFlavor.INVOKE with model_family=ANTHROPIC_CLAUDE uses
68+
UiPathChatAnthropicBedrock; ApiFlavor.INVOKE otherwise uses
69+
UiPathChatBedrock; None or ApiFlavor.CONVERSE uses
70+
UiPathChatBedrockConverse.
6971
custom_class: A custom class to use for instantiating the chat model instead of the
7072
auto-detected one. Must be a subclass of UiPathBaseChatModel. When provided,
7173
the factory skips vendor detection and uses this class directly.
@@ -189,6 +191,19 @@ def get_chat_model(
189191
)
190192
case VendorType.AWSBEDROCK:
191193
if api_flavor == ApiFlavor.INVOKE:
194+
if model_family == ModelFamily.ANTHROPIC_CLAUDE:
195+
from uipath_langchain_client.clients.bedrock.chat_models import (
196+
UiPathChatAnthropicBedrock,
197+
)
198+
199+
return UiPathChatAnthropicBedrock(
200+
model=model_name,
201+
settings=client_settings,
202+
byo_connection_id=byo_connection_id,
203+
model_details=model_details,
204+
**model_kwargs,
205+
)
206+
192207
from uipath_langchain_client.clients.bedrock.chat_models import (
193208
UiPathChatBedrock,
194209
)

tests/langchain/features/test_factory_function.py

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,11 @@ def test_openai_chat_respects_discovered_byom_chat_completions(
131131

132132

133133
class TestFactoryBedrockApiFlavorRouting:
134-
"""The AWSBEDROCK branch routes purely on ``api_flavor``:
134+
"""The AWSBEDROCK branch routes on ``api_flavor`` and ``model_family``:
135135
136-
- ``ApiFlavor.INVOKE`` -> ``UiPathChatBedrock``
136+
- ``ApiFlavor.INVOKE`` + ``ANTHROPIC_CLAUDE`` -> ``UiPathChatAnthropicBedrock``
137+
- ``ApiFlavor.INVOKE`` (other families) -> ``UiPathChatBedrock``
137138
- ``ApiFlavor.CONVERSE`` or ``None`` -> ``UiPathChatBedrockConverse``
138-
139-
Model family (e.g. ANTHROPIC_CLAUDE) no longer influences the choice.
140139
"""
141140

142141
def _patch_bedrock_classes(self, monkeypatch: pytest.MonkeyPatch) -> dict:
@@ -217,6 +216,45 @@ def test_invoke_api_flavor_uses_bedrock_invoke(self, monkeypatch: pytest.MonkeyP
217216
)
218217
assert chosen["class"] == "UiPathChatBedrock"
219218

219+
def test_invoke_api_flavor_with_anthropic_claude_uses_anthropic_bedrock(
220+
self, monkeypatch: pytest.MonkeyPatch
221+
):
222+
chosen = self._patch_bedrock_classes(monkeypatch)
223+
settings = self._settings_with_model_info(
224+
{
225+
"modelName": "anthropic.claude-3-5-sonnet-20240620-v1:0",
226+
"vendor": "AwsBedrock",
227+
"apiFlavor": None,
228+
"modelFamily": "AnthropicClaude",
229+
}
230+
)
231+
get_chat_model(
232+
model_name="anthropic.claude-3-5-sonnet-20240620-v1:0",
233+
client_settings=settings,
234+
api_flavor=ApiFlavor.INVOKE,
235+
)
236+
assert chosen["class"] == "UiPathChatAnthropicBedrock"
237+
238+
def test_converse_api_flavor_with_anthropic_claude_still_uses_converse(
239+
self, monkeypatch: pytest.MonkeyPatch
240+
):
241+
"""ANTHROPIC_CLAUDE only diverts to AnthropicBedrock on INVOKE — CONVERSE still wins."""
242+
chosen = self._patch_bedrock_classes(monkeypatch)
243+
settings = self._settings_with_model_info(
244+
{
245+
"modelName": "anthropic.claude-3-5-sonnet-20240620-v1:0",
246+
"vendor": "AwsBedrock",
247+
"apiFlavor": None,
248+
"modelFamily": "AnthropicClaude",
249+
}
250+
)
251+
get_chat_model(
252+
model_name="anthropic.claude-3-5-sonnet-20240620-v1:0",
253+
client_settings=settings,
254+
api_flavor=ApiFlavor.CONVERSE,
255+
)
256+
assert chosen["class"] == "UiPathChatBedrockConverse"
257+
220258

221259
class TestFactoryAgentHubConfig:
222260
"""The ``agenthub_config`` factory kwarg overrides ``client_settings.agenthub_config``

0 commit comments

Comments
 (0)