-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathtest_default_model_name.py
More file actions
131 lines (100 loc) · 4.23 KB
/
test_default_model_name.py
File metadata and controls
131 lines (100 loc) · 4.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import pytest
from pydantic import ValidationError
from uipath_langchain_client.clients.bedrock.chat_models import (
UiPathChatBedrockConverse as _UpstreamBedrockConverse,
)
from uipath_langchain_client.clients.normalized.chat_models import (
UiPathChat as _UpstreamUiPathChat,
)
from uipath_langchain.chat import (
UiPathAzureChatOpenAI,
UiPathChat,
UiPathChatAnthropic,
UiPathChatAnthropicBedrock,
UiPathChatAnthropicVertex,
UiPathChatBedrock,
UiPathChatBedrockConverse,
UiPathChatFireworks,
UiPathChatGoogleGenerativeAI,
UiPathChatOpenAI,
UiPathChatVertex,
)
_DEFAULT_OPENAI = "gpt-4.1-mini-2025-04-14"
_DEFAULT_BEDROCK = "anthropic.claude-haiku-4-5-20251001-v1:0"
_DEFAULT_VERTEX = "gemini-2.5-flash"
_FAKE_JWT = (
"eyJhbGciOiAiSFMyNTYiLCAidHlwIjogIkpXVCJ9."
"eyJzdWIiOiAidGVzdCIsICJpc3MiOiAidGVzdCJ9."
"signature"
)
@pytest.fixture(autouse=True)
def _platform_env(monkeypatch):
monkeypatch.setenv("UIPATH_ACCESS_TOKEN", _FAKE_JWT)
monkeypatch.setenv("UIPATH_URL", "https://example.com/org/tenant/orchestrator_/")
monkeypatch.setenv("UIPATH_TENANT_ID", "tenant")
monkeypatch.setenv("UIPATH_ORGANIZATION_ID", "org")
monkeypatch.delenv("UIPATH_MODEL_NAME", raising=False)
_CASES = [
(UiPathChat, _DEFAULT_OPENAI),
(UiPathAzureChatOpenAI, _DEFAULT_OPENAI),
(UiPathChatOpenAI, _DEFAULT_OPENAI),
(UiPathChatGoogleGenerativeAI, _DEFAULT_VERTEX),
(UiPathChatVertex, _DEFAULT_VERTEX),
(UiPathChatBedrock, _DEFAULT_BEDROCK),
(UiPathChatBedrockConverse, _DEFAULT_BEDROCK),
(UiPathChatAnthropicBedrock, _DEFAULT_BEDROCK),
]
@pytest.mark.parametrize("cls, expected", _CASES)
class TestInstantiationWithoutModelKwarg:
def test_no_args_uses_default(self, cls, expected):
llm = cls()
assert llm.model_name == expected
def test_explicit_model_kwarg_overrides_default(self, cls, expected):
llm = cls(model="custom-model-id")
assert llm.model_name == "custom-model-id"
def test_uipath_chat_no_args():
llm = UiPathChat()
assert llm.model_name == _DEFAULT_OPENAI
def test_uipath_chat_bedrock_no_args():
llm = UiPathChatBedrock()
assert llm.model_name == _DEFAULT_BEDROCK
def test_uipath_chat_bedrock_converse_no_args():
llm = UiPathChatBedrockConverse()
assert llm.model_name == _DEFAULT_BEDROCK
def test_uipath_chat_vertex_no_args():
llm = UiPathChatVertex()
assert llm.model_name == _DEFAULT_VERTEX
class TestUipathModelNameEnvVarOverride:
def test_env_var_overrides_openai_default(self, monkeypatch):
monkeypatch.setenv("UIPATH_MODEL_NAME", "custom-override")
llm = UiPathChat()
assert llm.model_name == "custom-override"
def test_env_var_overrides_bedrock_default(self, monkeypatch):
monkeypatch.setenv("UIPATH_MODEL_NAME", "custom-override")
llm = UiPathChatBedrock()
assert llm.model_name == "custom-override"
def test_env_var_overrides_bedrock_converse_default(self, monkeypatch):
monkeypatch.setenv("UIPATH_MODEL_NAME", "custom-override")
llm = UiPathChatBedrockConverse()
assert llm.model_name == "custom-override"
def test_env_var_overrides_vertex_default(self, monkeypatch):
monkeypatch.setenv("UIPATH_MODEL_NAME", "custom-override")
llm = UiPathChatGoogleGenerativeAI()
assert llm.model_name == "custom-override"
class TestExportsWithoutDefaults:
def test_anthropic_raises_without_model(self):
with pytest.raises(ValidationError, match="model"):
UiPathChatAnthropic()
def test_anthropic_vertex_raises_without_model(self):
with pytest.raises(ValidationError, match="model"):
UiPathChatAnthropicVertex()
def test_fireworks_raises_without_model(self):
with pytest.raises(ValidationError, match="model"):
UiPathChatFireworks()
class TestReExportedClassIdentity:
def test_uipath_chat_is_subclass_of_upstream(self):
assert issubclass(UiPathChat, _UpstreamUiPathChat)
def test_uipath_chat_vertex_alias_matches_google(self):
assert UiPathChatVertex is UiPathChatGoogleGenerativeAI
def test_bedrock_converse_is_subclass_of_upstream(self):
assert issubclass(UiPathChatBedrockConverse, _UpstreamBedrockConverse)