Skip to content

Commit e717775

Browse files
cosminachoclaude
andcommitted
Move is_anthropic_model_name helper to utils.model_family
constants.py is for enums and mappings, not utility functions. Relocate the helper + keyword tuple to a dedicated utils module and update all call sites to import from the new path. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent b0db28e commit e717775

7 files changed

Lines changed: 25 additions & 27 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ All notable changes to `uipath_llm_client` (core package) will be documented in
55
## [1.9.1] - 2026-04-17
66

77
### Added
8-
- `is_anthropic_model_name()` helper and `ANTHROPIC_MODEL_NAME_KEYWORDS` tuple in `settings.constants` — name-based Claude detection for BYOM deployments where discovery does not expose `modelFamily`
8+
- `utils.model_family.is_anthropic_model_name()` helper and `ANTHROPIC_MODEL_NAME_KEYWORDS` tuple — name-based Claude detection for BYOM deployments where discovery does not expose `modelFamily`
99

1010
### Fixed
1111
- `UiPathLiteLLM` now detects Claude-family models by name when `modelFamily` is unavailable (BYOM), correctly routing Bedrock/Vertex provider selection and default flavors

packages/uipath_langchain_client/src/uipath_langchain_client/clients/normalized/chat_models.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,9 @@
6464
from langchain_core.utils.pydantic import is_basemodel_subclass
6565
from pydantic import AliasChoices, BaseModel, Field
6666

67+
from uipath.llm_client.utils.model_family import is_anthropic_model_name
6768
from uipath_langchain_client.base_client import UiPathBaseChatModel
68-
from uipath_langchain_client.settings import (
69-
ApiType,
70-
RoutingMode,
71-
UiPathAPIConfig,
72-
is_anthropic_model_name,
73-
)
69+
from uipath_langchain_client.settings import ApiType, RoutingMode, UiPathAPIConfig
7470

7571
_DictOrPydanticClass = Union[dict[str, Any], type[BaseModel], type]
7672
_DictOrPydantic = Union[dict[str, Any], BaseModel]

packages/uipath_langchain_client/src/uipath_langchain_client/factory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
from typing import Any
2424

25+
from uipath.llm_client.utils.model_family import is_anthropic_model_name
2526
from uipath_langchain_client.base_client import (
2627
UiPathBaseChatModel,
2728
UiPathBaseEmbeddings,
@@ -35,7 +36,6 @@
3536
UiPathBaseSettings,
3637
VendorType,
3738
get_default_client_settings,
38-
is_anthropic_model_name,
3939
)
4040

4141

packages/uipath_langchain_client/src/uipath_langchain_client/settings.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
ModelFamily,
3232
RoutingMode,
3333
VendorType,
34-
is_anthropic_model_name,
3534
)
3635

3736
__all__ = [
@@ -48,5 +47,4 @@
4847
"VendorType",
4948
"API_FLAVOR_TO_VENDOR_TYPE",
5049
"BYOM_TO_ROUTING_FLAVOR",
51-
"is_anthropic_model_name",
5250
]

src/uipath/llm_client/clients/litellm/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
ModelFamily,
3535
RoutingMode,
3636
VendorType,
37-
is_anthropic_model_name,
3837
)
38+
from uipath.llm_client.utils.model_family import is_anthropic_model_name
3939
from uipath.llm_client.utils.retry import RetryConfig
4040

4141
# Route OpenAI chat completions through base_llm_http_handler (accepts HTTPHandler)

src/uipath/llm_client/settings/constants.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,3 @@ class ByomApiFlavor(StrEnum):
7070
ByomApiFlavor.AWS_BEDROCK_INVOKE: ApiFlavor.INVOKE,
7171
ByomApiFlavor.AWS_BEDROCK_CONVERSE: ApiFlavor.CONVERSE,
7272
}
73-
74-
75-
ANTHROPIC_MODEL_NAME_KEYWORDS: tuple[str, ...] = (
76-
"anthropic",
77-
"claude",
78-
"opus",
79-
"sonnet",
80-
"haiku",
81-
"mythos",
82-
)
83-
84-
85-
def is_anthropic_model_name(model_name: str) -> bool:
86-
"""Heuristic fallback for when discovery's ``modelFamily`` is unavailable (e.g. BYOM)."""
87-
lower = model_name.lower()
88-
return any(kw in lower for kw in ANTHROPIC_MODEL_NAME_KEYWORDS)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"""Heuristic helpers for identifying a model's family from its name.
2+
3+
Discovery metadata (``modelFamily``) is the authoritative source, but BYOM
4+
deployments do not expose it. These helpers provide a name-based fallback.
5+
"""
6+
7+
ANTHROPIC_MODEL_NAME_KEYWORDS: tuple[str, ...] = (
8+
"anthropic",
9+
"claude",
10+
"opus",
11+
"sonnet",
12+
"haiku",
13+
"mythos",
14+
)
15+
16+
17+
def is_anthropic_model_name(model_name: str) -> bool:
18+
"""Return True if ``model_name`` looks like an Anthropic Claude-family model."""
19+
lower = model_name.lower()
20+
return any(kw in lower for kw in ANTHROPIC_MODEL_NAME_KEYWORDS)

0 commit comments

Comments
 (0)