uipath-langchain 0.0.123__py3-none-any.whl → 0.0.125__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of uipath-langchain might be problematic. Click here for more details.

@@ -18,6 +18,7 @@ from uipath._cli._runtime._contracts import (
18
18
 
19
19
  from ..._utils import _instrument_traceable_attributes
20
20
  from ...tracers import AsyncUiPathTracer
21
+ from .._utils._graph import LangGraphConfig
21
22
  from ._context import LangGraphRuntimeContext
22
23
  from ._exception import LangGraphRuntimeError
23
24
  from ._input import LangGraphInputProcessor
@@ -56,11 +57,6 @@ class LangGraphRuntime(UiPathBaseRuntime):
56
57
  tracer = None
57
58
 
58
59
  try:
59
- if self.context.resume is False and self.context.job_id is None:
60
- # Delete the previous graph state file at debug time
61
- if os.path.exists(self.state_file_path):
62
- os.remove(self.state_file_path)
63
-
64
60
  async with AsyncSqliteSaver.from_conn_string(
65
61
  self.state_file_path
66
62
  ) as memory:
@@ -85,9 +81,11 @@ class LangGraphRuntime(UiPathBaseRuntime):
85
81
 
86
82
  graph_config: RunnableConfig = {
87
83
  "configurable": {
88
- "thread_id": self.context.job_id
89
- if self.context.job_id
90
- else "default"
84
+ "thread_id": (
85
+ self.context.execution_id
86
+ or self.context.job_id
87
+ or "default"
88
+ )
91
89
  },
92
90
  "callbacks": callbacks,
93
91
  }
@@ -190,12 +188,14 @@ class LangGraphRuntime(UiPathBaseRuntime):
190
188
  ) from e
191
189
 
192
190
  if self.context.langgraph_config is None:
193
- raise LangGraphRuntimeError(
194
- "CONFIG_MISSING",
195
- "Invalid configuration",
196
- "Failed to load configuration",
197
- UiPathErrorCategory.DEPLOYMENT,
198
- )
191
+ self.context.langgraph_config = LangGraphConfig()
192
+ if not self.context.langgraph_config.exists:
193
+ raise LangGraphRuntimeError(
194
+ "CONFIG_MISSING",
195
+ "Invalid configuration",
196
+ "Failed to load configuration",
197
+ UiPathErrorCategory.DEPLOYMENT,
198
+ )
199
199
 
200
200
  try:
201
201
  self.context.langgraph_config.load_config()
@@ -0,0 +1,41 @@
1
+ import asyncio
2
+ from typing import Optional
3
+
4
+ from openinference.instrumentation.langchain import (
5
+ LangChainInstrumentor,
6
+ get_current_span,
7
+ )
8
+ from uipath._cli._dev._terminal import UiPathDevTerminal
9
+ from uipath._cli._runtime._contracts import UiPathRuntimeFactory
10
+ from uipath._cli._utils._console import ConsoleLogger
11
+ from uipath._cli.middlewares import MiddlewareResult
12
+
13
+ from ._runtime._context import LangGraphRuntimeContext
14
+ from ._runtime._runtime import LangGraphRuntime
15
+
16
+ console = ConsoleLogger()
17
+
18
+
19
+ def langgraph_dev_middleware(interface: Optional[str]) -> MiddlewareResult:
20
+ """Middleware to launch the developer terminal"""
21
+
22
+ try:
23
+ if interface == "terminal":
24
+ runtime_factory = UiPathRuntimeFactory(
25
+ LangGraphRuntime, LangGraphRuntimeContext
26
+ )
27
+ runtime_factory.add_instrumentor(LangChainInstrumentor, get_current_span)
28
+ app = UiPathDevTerminal(runtime_factory)
29
+ asyncio.run(app.run_async())
30
+ else:
31
+ console.error(f"Unknown interface: {interface}")
32
+ except KeyboardInterrupt:
33
+ console.info("Debug session interrupted by user")
34
+ except Exception as e:
35
+ console.error(f"Error occurred: {e}")
36
+ return MiddlewareResult(
37
+ should_continue=False,
38
+ should_include_stacktrace=True,
39
+ )
40
+
41
+ return MiddlewareResult(should_continue=False)
@@ -1,4 +1,5 @@
1
1
  import asyncio
2
+ import os
2
3
  from os import environ as env
3
4
  from typing import Optional
4
5
 
@@ -40,7 +41,8 @@ def langgraph_run_middleware(
40
41
  context.langgraph_config = config
41
42
  context.debug = kwargs.get("debug", False)
42
43
  context.logs_min_level = env.get("LOG_LEVEL", "INFO")
43
- context.job_id = env.get("UIPATH_JOB_KEY")
44
+ context.job_id = env.get("UIPATH_JOB_KEY", None)
45
+ context.execution_id = env.get("UIPATH_JOB_KEY", None)
44
46
  context.trace_id = env.get("UIPATH_TRACE_ID")
45
47
  context.is_eval_run = kwargs.get("is_eval_run", False)
46
48
  context.tracing_enabled = tracing
@@ -64,6 +66,10 @@ def langgraph_run_middleware(
64
66
  env["UIPATH_REQUESTING_FEATURE"] = "langgraph-agent"
65
67
 
66
68
  async with LangGraphRuntime.from_context(context) as runtime:
69
+ if context.resume is False and context.job_id is None:
70
+ # Delete the previous graph state file at debug time
71
+ if os.path.exists(runtime.state_file_path):
72
+ os.remove(runtime.state_file_path)
67
73
  await runtime.execute()
68
74
 
69
75
  asyncio.run(execute())
@@ -9,7 +9,7 @@ import httpx
9
9
  import openai
10
10
  from langchain_core.embeddings import Embeddings
11
11
  from langchain_core.language_models.chat_models import _cleanup_llm_representation
12
- from pydantic import BaseModel, Field, SecretStr
12
+ from pydantic import BaseModel, ConfigDict, Field, SecretStr
13
13
  from tenacity import (
14
14
  AsyncRetrying,
15
15
  Retrying,
@@ -37,8 +37,7 @@ def get_from_uipath_url():
37
37
 
38
38
 
39
39
  class UiPathRequestMixin(BaseModel):
40
- class Config:
41
- arbitrary_types_allowed = True
40
+ model_config = ConfigDict(arbitrary_types_allowed=True)
42
41
 
43
42
  default_headers: Optional[Mapping[str, str]] = {
44
43
  "X-UiPath-Streaming-Enabled": "false",
@@ -0,0 +1,191 @@
1
+ from enum import Enum
2
+ from typing import Annotated, Any, Dict, List, Literal, Optional, Union
3
+
4
+ from pydantic import BaseModel, ConfigDict, Field
5
+
6
+
7
+ class AgentMessageRole(str, Enum):
8
+ """Enum for message roles"""
9
+
10
+ SYSTEM = "System"
11
+ USER = "User"
12
+
13
+
14
+ class AgentMessage(BaseModel):
15
+ """Message model for agent conversations"""
16
+
17
+ role: AgentMessageRole
18
+ content: str
19
+
20
+ model_config = ConfigDict(
21
+ validate_by_name=True, validate_by_alias=True, extra="allow"
22
+ )
23
+
24
+
25
+ class AgentSettings(BaseModel):
26
+ """Settings for agent configuration"""
27
+
28
+ engine: str = Field(..., description="Engine type, e.g., 'basic-v1'")
29
+ model: str = Field(..., description="LLM model identifier")
30
+ max_tokens: int = Field(
31
+ ..., alias="maxTokens", description="Maximum number of tokens"
32
+ )
33
+ temperature: float = Field(..., description="Temperature for response generation")
34
+
35
+ model_config = ConfigDict(
36
+ validate_by_name=True, validate_by_alias=True, extra="allow"
37
+ )
38
+
39
+
40
+ class AgentResourceType(str, Enum):
41
+ """Enum for resource types"""
42
+
43
+ TOOL = "tool"
44
+ CONTEXT = "context"
45
+ ESCALATION = "escalation"
46
+
47
+
48
+ class AgentBaseResourceConfig(BaseModel):
49
+ """Base resource model with common properties"""
50
+
51
+ name: str
52
+ description: str
53
+
54
+ model_config = ConfigDict(
55
+ validate_by_name=True, validate_by_alias=True, extra="allow"
56
+ )
57
+
58
+
59
+ class AgentUnknownResourceConfig(AgentBaseResourceConfig):
60
+ """Fallback for unknown or future resource types"""
61
+
62
+ resource_type: str = Field(alias="$resourceType")
63
+
64
+ model_config = ConfigDict(extra="allow")
65
+
66
+
67
+ class AgentToolSettings(BaseModel):
68
+ """Settings for tool configuration"""
69
+
70
+ max_attempts: int = Field(0, alias="maxAttempts")
71
+ retry_delay: int = Field(0, alias="retryDelay")
72
+ timeout: int = Field(0)
73
+
74
+ model_config = ConfigDict(
75
+ validate_by_name=True, validate_by_alias=True, extra="allow"
76
+ )
77
+
78
+
79
+ class AgentToolProperties(BaseModel):
80
+ """Properties specific to tool configuration"""
81
+
82
+ folder_path: Optional[str] = Field(None, alias="folderPath")
83
+ process_name: Optional[str] = Field(None, alias="processName")
84
+
85
+ model_config = ConfigDict(
86
+ validate_by_name=True, validate_by_alias=True, extra="allow"
87
+ )
88
+
89
+
90
+ class AgentToolResourceConfig(AgentBaseResourceConfig):
91
+ """Tool resource with tool-specific properties"""
92
+
93
+ resource_type: Literal[AgentResourceType.TOOL] = Field(alias="$resourceType")
94
+ type: str = Field(..., description="Tool type")
95
+ arguments: Dict[str, Any] = Field(
96
+ default_factory=dict, description="Tool arguments"
97
+ )
98
+ input_schema: Dict[str, Any] = Field(
99
+ ..., alias="inputSchema", description="Input schema for the tool"
100
+ )
101
+ output_schema: Dict[str, Any] = Field(
102
+ ..., alias="outputSchema", description="Output schema for the tool"
103
+ )
104
+ properties: AgentToolProperties = Field(..., description="Tool-specific properties")
105
+ settings: AgentToolSettings = Field(
106
+ default_factory=AgentToolSettings, description="Tool settings"
107
+ )
108
+
109
+ model_config = ConfigDict(
110
+ validate_by_name=True, validate_by_alias=True, extra="allow"
111
+ )
112
+
113
+
114
+ class AgentContextSettings(BaseModel):
115
+ """Settings for context configuration"""
116
+
117
+ result_count: int = Field(alias="resultCount")
118
+ retrieval_mode: Literal["Semantic", "Structured"] = Field(alias="retrievalMode")
119
+ threshold: float = Field(default=0)
120
+
121
+ model_config = ConfigDict(
122
+ validate_by_name=True, validate_by_alias=True, extra="allow"
123
+ )
124
+
125
+
126
+ class AgentContextResourceConfig(AgentBaseResourceConfig):
127
+ """Context resource with context-specific properties"""
128
+
129
+ resource_type: Literal[AgentResourceType.CONTEXT] = Field(alias="$resourceType")
130
+ folder_path: str = Field(alias="folderPath")
131
+ index_name: str = Field(alias="indexName")
132
+ settings: AgentContextSettings = Field(..., description="Context settings")
133
+
134
+ model_config = ConfigDict(
135
+ validate_by_name=True, validate_by_alias=True, extra="allow"
136
+ )
137
+
138
+
139
+ class AgentEscalationResourceConfig(AgentBaseResourceConfig):
140
+ """Escalation resource with escalation-specific properties"""
141
+
142
+ resource_type: Literal[AgentResourceType.ESCALATION] = Field(alias="$resourceType")
143
+
144
+ model_config = ConfigDict(
145
+ validate_by_name=True, validate_by_alias=True, extra="allow"
146
+ )
147
+
148
+
149
+ # Discriminated union for known types
150
+ KnownAgentResourceConfig = Annotated[
151
+ Union[
152
+ AgentToolResourceConfig,
153
+ AgentContextResourceConfig,
154
+ AgentEscalationResourceConfig,
155
+ ],
156
+ Field(discriminator="resource_type"),
157
+ ]
158
+
159
+ # Final union includes unknowns as a catch-all
160
+ AgentResourceConfig = Union[
161
+ KnownAgentResourceConfig,
162
+ AgentUnknownResourceConfig,
163
+ ]
164
+
165
+
166
+ class AgentConfig(BaseModel):
167
+ """Main agent model"""
168
+
169
+ id: str = Field(..., description="Agent id or project name")
170
+ name: str = Field(..., description="Agent name or project name")
171
+ input_schema: Dict[str, Any] = Field(
172
+ ..., alias="inputSchema", description="JSON schema for input arguments"
173
+ )
174
+ output_schema: Dict[str, Any] = Field(
175
+ ..., alias="outputSchema", description="JSON schema for output arguments"
176
+ )
177
+ messages: List[AgentMessage] = Field(
178
+ ..., description="List of system and user messages"
179
+ )
180
+ features: List[Any] = Field(
181
+ default_factory=list, description="Currently empty feature list"
182
+ )
183
+ version: str = Field("1.0.0", description="Agent version")
184
+ settings: AgentSettings = Field(..., description="Agent settings configuration")
185
+ resources: List[AgentResourceConfig] = Field(
186
+ ..., description="List of tools, context, and escalation resources"
187
+ )
188
+
189
+ model_config = ConfigDict(
190
+ validate_by_name=True, validate_by_alias=True, extra="allow"
191
+ )
@@ -1,5 +1,6 @@
1
1
  from uipath._cli.middlewares import Middlewares
2
2
 
3
+ from ._cli.cli_dev import langgraph_dev_middleware
3
4
  from ._cli.cli_init import langgraph_init_middleware
4
5
  from ._cli.cli_new import langgraph_new_middleware
5
6
  from ._cli.cli_run import langgraph_run_middleware
@@ -10,3 +11,4 @@ def register_middleware():
10
11
  Middlewares.register("init", langgraph_init_middleware)
11
12
  Middlewares.register("run", langgraph_run_middleware)
12
13
  Middlewares.register("new", langgraph_new_middleware)
14
+ Middlewares.register("dev", langgraph_dev_middleware)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: uipath-langchain
3
- Version: 0.0.123
3
+ Version: 0.0.125
4
4
  Summary: UiPath Langchain
5
5
  Project-URL: Homepage, https://uipath.com
6
6
  Project-URL: Repository, https://github.com/UiPath/uipath-langchain-python
@@ -22,9 +22,10 @@ Requires-Dist: langchain>=0.3.4
22
22
  Requires-Dist: langgraph-checkpoint-sqlite>=2.0.3
23
23
  Requires-Dist: langgraph<0.7.0,>=0.5.0
24
24
  Requires-Dist: openai>=1.65.5
25
+ Requires-Dist: openinference-instrumentation-langchain>=0.1.50
25
26
  Requires-Dist: pydantic-settings>=2.6.0
26
27
  Requires-Dist: python-dotenv>=1.0.1
27
- Requires-Dist: uipath<2.2.0,>=2.1.10
28
+ Requires-Dist: uipath<2.2.0,>=2.1.33
28
29
  Provides-Extra: langchain
29
30
  Description-Content-Type: text/markdown
30
31
 
@@ -1,21 +1,23 @@
1
1
  uipath_langchain/__init__.py,sha256=VBrvQn7d3nuOdN7zEnV2_S-uhmkjgEIlXiFVeZxZakQ,80
2
- uipath_langchain/middlewares.py,sha256=tre7o9DFMgWk1DJiEEUmT6_wiP-PPkWtKmG0iOyvr9c,509
2
+ uipath_langchain/middlewares.py,sha256=EOWVTr52SFLEf5lzGAvcDN2qbtPsy4_EsFoXlV-cqdY,618
3
3
  uipath_langchain/_cli/__init__.py,sha256=juqd9PbXs4yg45zMJ7BHAOPQjb7sgEbWE9InBtGZhfo,24
4
+ uipath_langchain/_cli/cli_dev.py,sha256=VlI8qgCw-63I97tp_9lbXs-CVcNSjpd2sC13YNZAIuU,1401
4
5
  uipath_langchain/_cli/cli_init.py,sha256=xhxJ8tuMSrVUNHvltgyPpOrvgMA-wq9shHeYYwvHILs,8199
5
6
  uipath_langchain/_cli/cli_new.py,sha256=dL8-Rri6u67ZZdbb4nT38A5xD_Q3fVnG0UK9VSeKaqg,2563
6
- uipath_langchain/_cli/cli_run.py,sha256=Jr-nxzBaSPQoVrdV1nQBSDVFElFV3N0a0uNDDrdSc8I,3375
7
+ uipath_langchain/_cli/cli_run.py,sha256=R-cUi3lO3Qd4ysTXD7PW4sa1RsB427v_Y6xUQxWijfQ,3725
7
8
  uipath_langchain/_cli/_runtime/_context.py,sha256=yyzYJDmk2fkH4T5gm4cLGRyXtjLESrpzHBT9euqluTA,817
8
9
  uipath_langchain/_cli/_runtime/_exception.py,sha256=USKkLYkG-dzjX3fEiMMOHnVUpiXJs_xF0OQXCCOvbYM,546
9
10
  uipath_langchain/_cli/_runtime/_input.py,sha256=vZ8vfVxvPSaPWmIPghvNx1VRKzbalHsKUMBPiKDvJWM,5492
10
11
  uipath_langchain/_cli/_runtime/_output.py,sha256=yJOZPWv2FRUJWv1NRs9JmpB4QMTDXu8jrxoaKrfJvzw,9078
11
- uipath_langchain/_cli/_runtime/_runtime.py,sha256=XTlPaMuHyv-4DjQMoEh76D2Z18M3S5wm4tDP-UAiE5Y,14505
12
+ uipath_langchain/_cli/_runtime/_runtime.py,sha256=dRM28l1k3qFf8NLWytRKlOcPwZJ__qUjqmV04wN9JRY,14504
12
13
  uipath_langchain/_cli/_templates/langgraph.json.template,sha256=eeh391Gta_hoRgaNaZ58nW1LNvCVXA7hlAH6l7Veous,107
13
14
  uipath_langchain/_cli/_templates/main.py.template,sha256=nMJQIYPlRk90iANfNVpkJ2EQX20Dxsyq92-BucEz_UM,1189
14
15
  uipath_langchain/_cli/_utils/_graph.py,sha256=JPShHNl0UQvl4AdjLIqLpNt_JAjpWH9WWF22Gs47Xew,7445
15
16
  uipath_langchain/_utils/__init__.py,sha256=WoY66enCygRXTh6v5B1UrRcFCnQYuPJ8oqDkwomXzLc,194
16
- uipath_langchain/_utils/_request_mixin.py,sha256=Tr57358_dwb7SQ1OU75XjdFVWEIr05-QJifeJfHHZgc,19680
17
+ uipath_langchain/_utils/_request_mixin.py,sha256=ddKFs_0mjoFCmvPTiOTPJh1IIqYUo5CUka-B7zAZphE,19695
17
18
  uipath_langchain/_utils/_settings.py,sha256=2fExMQJ88YptfldmzMfZIpsx-m1gfMkeYGf5t6KIe0A,3084
18
19
  uipath_langchain/_utils/_sleep_policy.py,sha256=e9pHdjmcCj4CVoFM1jMyZFelH11YatsgWfpyrfXzKBQ,1251
20
+ uipath_langchain/builder/agent_config.py,sha256=b9WODKPjvufj41Ow_dQn5CnaTAjAZyQoNhuAl8vfiso,5809
19
21
  uipath_langchain/chat/__init__.py,sha256=WDcvy91ixvZ3Mq7Ae94g5CjyQwXovDBnEv1NlD5SXBE,116
20
22
  uipath_langchain/chat/models.py,sha256=m5PRAFXzUamt6-1K9uSlWUvZg_NfVyYHkgoQDJ-1rGs,10527
21
23
  uipath_langchain/embeddings/__init__.py,sha256=QICtYB58ZyqFfDQrEaO8lTEgAU5NuEKlR7iIrS0OBtc,156
@@ -29,8 +31,8 @@ uipath_langchain/tracers/_instrument_traceable.py,sha256=0e841zVzcPWjOGtmBx0GeHb
29
31
  uipath_langchain/tracers/_utils.py,sha256=JOT1tKMdvqjMDtj2WbmbOWMeMlTXBWavxWpogX7KlRA,1543
30
32
  uipath_langchain/vectorstores/__init__.py,sha256=w8qs1P548ud1aIcVA_QhBgf_jZDrRMK5Lono78yA8cs,114
31
33
  uipath_langchain/vectorstores/context_grounding_vectorstore.py,sha256=TncIXG-YsUlO0R5ZYzWsM-Dj1SVCZbzmo2LraVxXelc,9559
32
- uipath_langchain-0.0.123.dist-info/METADATA,sha256=YfxavLE3bBdZlDjaKgBnX410AeHdIg6tEFZpQInaBjA,4172
33
- uipath_langchain-0.0.123.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
34
- uipath_langchain-0.0.123.dist-info/entry_points.txt,sha256=FUtzqGOEntlJKMJIXhQUfT7ZTbQmGhke1iCmDWZaQZI,81
35
- uipath_langchain-0.0.123.dist-info/licenses/LICENSE,sha256=JDpt-uotAkHFmxpwxi6gwx6HQ25e-lG4U_Gzcvgp7JY,1063
36
- uipath_langchain-0.0.123.dist-info/RECORD,,
34
+ uipath_langchain-0.0.125.dist-info/METADATA,sha256=-qGeRLnvPNVGjyNyQRn5SQ0bgd8Kn07sgfgmVCYfihg,4235
35
+ uipath_langchain-0.0.125.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
36
+ uipath_langchain-0.0.125.dist-info/entry_points.txt,sha256=FUtzqGOEntlJKMJIXhQUfT7ZTbQmGhke1iCmDWZaQZI,81
37
+ uipath_langchain-0.0.125.dist-info/licenses/LICENSE,sha256=JDpt-uotAkHFmxpwxi6gwx6HQ25e-lG4U_Gzcvgp7JY,1063
38
+ uipath_langchain-0.0.125.dist-info/RECORD,,