Skip to content

Commit c4efcd8

Browse files
authored
feat: Add uipath_langchain_client, refactor code to use the new client (#634)
1 parent b74f135 commit c4efcd8

69 files changed

Lines changed: 4907 additions & 3459 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

pyproject.toml

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "uipath-langchain"
3-
version = "0.9.36"
3+
version = "0.10.0"
44
description = "Python SDK that enables developers to build and deploy LangGraph agents to the UiPath Cloud Platform"
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.11"
@@ -12,7 +12,6 @@ dependencies = [
1212
"langgraph>=1.1.8, <2.0.0",
1313
"langchain-core>=1.2.11, <2.0.0",
1414
"langgraph-checkpoint-sqlite>=3.0.3, <4.0.0",
15-
"langchain-openai>=1.0.0, <2.0.0",
1615
"langchain>=1.0.0, <2.0.0",
1716
"pydantic-settings>=2.6.0",
1817
"python-dotenv>=1.0.1",
@@ -24,6 +23,7 @@ dependencies = [
2423
"langchain-mcp-adapters==0.2.1",
2524
"pillow>=12.1.1",
2625
"a2a-sdk>=0.2.0,<1.0.0",
26+
"uipath-langchain-client[openai]>=1.9.8",
2727
]
2828

2929
classifiers = [
@@ -39,8 +39,23 @@ maintainers = [
3939
]
4040

4141
[project.optional-dependencies]
42-
vertex = ["langchain-google-genai>=2.0.0", "google-generativeai>=0.8.0"]
43-
bedrock = ["langchain-aws>=0.2.35", "boto3-stubs>=1.41.4"]
42+
anthropic = [
43+
"uipath-langchain-client[anthropic]>=1.9.8",
44+
]
45+
vertex = [
46+
"uipath-langchain-client[google]>=1.9.8",
47+
"uipath-langchain-client[vertexai]>=1.9.8",
48+
]
49+
bedrock = [
50+
"uipath-langchain-client[bedrock]>=1.9.8",
51+
"boto3-stubs>=1.41.4",
52+
]
53+
fireworks = [
54+
"uipath-langchain-client[fireworks]>=1.9.8",
55+
]
56+
all = [
57+
"uipath-langchain-client[all]>=1.9.8",
58+
]
4459

4560
[project.entry-points."uipath.middlewares"]
4661
register = "uipath_langchain.middlewares:register_middleware"
@@ -86,8 +101,8 @@ select = ["E", "F", "B", "I"]
86101

87102
[tool.ruff.lint.per-file-ignores]
88103
"*" = ["E501"]
89-
"src/uipath_langchain/chat/bedrock.py" = ["E402"]
90-
"src/uipath_langchain/chat/vertex.py" = ["E402"]
104+
"src/uipath_langchain/chat/_legacy/bedrock.py" = ["E402"]
105+
"src/uipath_langchain/chat/_legacy/vertex.py" = ["E402"]
91106

92107
[tool.ruff.format]
93108
quote-style = "double"
@@ -121,3 +136,4 @@ name = "testpypi"
121136
url = "https://test.pypi.org/simple/"
122137
publish-url = "https://test.pypi.org/legacy/"
123138
explicit = true
139+

samples/joke-agent-decorator/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description = "Joke generating agent that creates family-friendly jokes based on
55
authors = [{ name = "John Doe", email = "john.doe@myemail.com" }]
66
requires-python = ">=3.11"
77
dependencies = [
8-
"uipath-langchain>=0.9.26, <0.10.0",
8+
"uipath-langchain>=0.9.26, <0.11.0",
99
"uipath>2.7.0",
1010
]
1111

samples/joke-agent/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description = "Joke generating agent that creates family-friendly jokes based on
55
authors = [{ name = "John Doe", email = "john.doe@myemail.com" }]
66
requires-python = ">=3.11"
77
dependencies = [
8-
"uipath-langchain>=0.9.26, <0.10.0",
8+
"uipath-langchain>=0.9.26, <0.11.0",
99
"uipath>2.7.0",
1010
]
1111

src/uipath_langchain/_utils/_request_mixin.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@
3434
get_uipath_token_header,
3535
)
3636
from uipath_langchain._utils._sleep_policy import before_sleep_log
37-
from uipath_langchain.chat.http_client import build_uipath_headers, resolve_gateway_url
37+
from uipath_langchain.chat._legacy.http_client import (
38+
build_uipath_headers,
39+
resolve_gateway_url,
40+
)
3841
from uipath_langchain.runtime.errors import (
3942
LangGraphErrorCode,
4043
LangGraphRuntimeError,

src/uipath_langchain/agent/react/init_node.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def create_init_node(
2020
):
2121
def graph_state_init(state: Any) -> Any:
2222
resolved_messages: Sequence[SystemMessage | HumanMessage] | Overwrite
23+
preserved_messages: Sequence[Any] = []
2324
if callable(messages):
2425
resolved_messages = list(messages(state))
2526
else:

src/uipath_langchain/chat/__init__.py

Lines changed: 73 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,56 +11,113 @@
1111
Instead, all exports are loaded on-demand when first accessed.
1212
"""
1313

14+
from .hitl import (
15+
request_approval,
16+
request_conversational_tool_confirmation,
17+
requires_approval,
18+
)
19+
1420

1521
def __getattr__(name):
16-
if name == "UiPathAzureChatOpenAI":
17-
from .models import UiPathAzureChatOpenAI
22+
if name == "get_chat_model":
23+
from .chat_model_factory import get_chat_model
1824

19-
return UiPathAzureChatOpenAI
25+
return get_chat_model
2026
if name == "UiPathChat":
21-
from .models import UiPathChat
27+
from uipath_langchain_client.clients.normalized.chat_models import (
28+
UiPathChat,
29+
)
2230

2331
return UiPathChat
32+
if name == "UiPathAzureChatOpenAI":
33+
from uipath_langchain_client.clients.openai.chat_models import (
34+
UiPathAzureChatOpenAI,
35+
)
36+
37+
return UiPathAzureChatOpenAI
2438
if name == "UiPathChatOpenAI":
25-
from .openai import UiPathChatOpenAI
39+
from uipath_langchain_client.clients.openai.chat_models import (
40+
UiPathChatOpenAI,
41+
)
2642

2743
return UiPathChatOpenAI
28-
if name == "requires_approval":
29-
from .hitl import requires_approval
44+
if name == "UiPathChatGoogleGenerativeAI":
45+
from uipath_langchain_client.clients.google.chat_models import (
46+
UiPathChatGoogleGenerativeAI,
47+
)
48+
49+
return UiPathChatGoogleGenerativeAI
50+
if name == "UiPathChatBedrock":
51+
from uipath_langchain_client.clients.bedrock.chat_models import (
52+
UiPathChatBedrock,
53+
)
3054

31-
return requires_approval
32-
if name in ("UiPathChatBedrock", "UiPathChatBedrockConverse"):
33-
from .bedrock import UiPathChatBedrock, UiPathChatBedrockConverse
55+
return UiPathChatBedrock
56+
if name == "UiPathChatBedrockConverse":
57+
from uipath_langchain_client.clients.bedrock.chat_models import (
58+
UiPathChatBedrockConverse,
59+
)
3460

35-
if name == "UiPathChatBedrock":
36-
return UiPathChatBedrock
3761
return UiPathChatBedrockConverse
62+
if name == "UiPathChatAnthropicBedrock":
63+
from uipath_langchain_client.clients.bedrock.chat_models import (
64+
UiPathChatAnthropicBedrock,
65+
)
66+
67+
return UiPathChatAnthropicBedrock
68+
if name == "UiPathChatAnthropic":
69+
from uipath_langchain_client.clients.anthropic.chat_models import (
70+
UiPathChatAnthropic,
71+
)
72+
73+
return UiPathChatAnthropic
74+
if name == "UiPathChatAnthropicVertex":
75+
from uipath_langchain_client.clients.vertexai.chat_models import (
76+
UiPathChatAnthropicVertex,
77+
)
78+
79+
return UiPathChatAnthropicVertex
80+
if name == "UiPathChatFireworks":
81+
from uipath_langchain_client.clients.fireworks.chat_models import (
82+
UiPathChatFireworks,
83+
)
84+
85+
return UiPathChatFireworks
3886
if name == "UiPathChatVertex":
39-
from .vertex import UiPathChatVertex
87+
from uipath_langchain.chat._legacy.vertex import UiPathChatVertex
4088

4189
return UiPathChatVertex
4290
if name in ("OpenAIModels", "BedrockModels", "GeminiModels"):
43-
from . import supported_models
91+
from uipath_langchain.chat._legacy import supported_models
4492

4593
return getattr(supported_models, name)
4694
if name in ("LLMProvider", "APIFlavor"):
47-
from . import types
95+
from uipath_langchain.chat._legacy import types
4896

4997
return getattr(types, name)
98+
5099
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
51100

52101

53102
__all__ = [
103+
"get_chat_model",
54104
"UiPathChat",
55105
"UiPathAzureChatOpenAI",
56106
"UiPathChatOpenAI",
107+
"UiPathChatGoogleGenerativeAI",
57108
"UiPathChatBedrock",
58109
"UiPathChatBedrockConverse",
110+
"UiPathChatAnthropicBedrock",
111+
"UiPathChatAnthropic",
112+
"UiPathChatAnthropicVertex",
113+
"UiPathChatFireworks",
59114
"UiPathChatVertex",
60115
"OpenAIModels",
61116
"BedrockModels",
62117
"GeminiModels",
63-
"requires_approval",
64118
"LLMProvider",
65119
"APIFlavor",
120+
"request_approval",
121+
"request_conversational_tool_confirmation",
122+
"requires_approval",
66123
]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
"""Legacy LLM client implementation retained for the EnabledNewLlmClients feature flag.
2+
3+
This package hosts the pre-commit-3f7da07d chat client code. It is used when the
4+
``EnabledNewLlmClients`` feature flag is False so that behavior matches the
5+
implementation that preceded the ``uipath_langchain_client`` migration.
6+
"""

0 commit comments

Comments
 (0)