langchain-arcade 1.3.0__py3-none-any.whl → 1.4.4__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.
@@ -53,7 +53,9 @@ def tool_definition_to_pydantic_model(tool_def: ToolDefinition) -> type[BaseMode
53
53
  for param in tool_def.input.parameters or []:
54
54
  param_type = get_python_type(param.value_schema.val_type)
55
55
  if param_type == list and param.value_schema.inner_val_type: # noqa: E721
56
- inner_type: type[Any] = get_python_type(param.value_schema.inner_val_type)
56
+ inner_type: type[Any] = get_python_type(
57
+ param.value_schema.inner_val_type
58
+ )
57
59
  param_type = list[inner_type] # type: ignore[valid-type]
58
60
  param_description = param.description or "No description provided."
59
61
  default = ... if param.required else None
@@ -90,9 +92,14 @@ def process_tool_execution_response(
90
92
  "tool": tool_name,
91
93
  }
92
94
 
93
- if execute_response.output is not None and execute_response.output.error is not None:
95
+ if (
96
+ execute_response.output is not None
97
+ and execute_response.output.error is not None
98
+ ):
94
99
  error = execute_response.output.error
95
- error_message = str(error.message) if hasattr(error, "message") else "Unknown error"
100
+ error_message = (
101
+ str(error.message) if hasattr(error, "message") else "Unknown error"
102
+ )
96
103
  error_details["error"] = error_message
97
104
 
98
105
  # Add all non-None optional error fields to the details
@@ -133,10 +140,13 @@ def create_tool_function(
133
140
  A callable function that executes the tool.
134
141
  """
135
142
  if langgraph and not LANGGRAPH_ENABLED:
136
- raise ImportError("LangGraph is not installed. Please install it to use this feature.")
143
+ raise ImportError(
144
+ "LangGraph is not installed. Please install it to use this feature."
145
+ )
137
146
 
138
147
  requires_authorization = (
139
- tool_def.requirements is not None and tool_def.requirements.authorization is not None
148
+ tool_def.requirements is not None
149
+ and tool_def.requirements.authorization is not None
140
150
  )
141
151
 
142
152
  def tool_function(config: RunnableConfig, **kwargs: Any) -> Any:
@@ -161,7 +171,9 @@ def create_tool_function(
161
171
  # Authorize the user for the tool
162
172
  auth_response = client.tools.authorize(tool_name=tool_name, user_id=user_id)
163
173
  if auth_response.status != "completed":
164
- auth_message = f"Please use the following link to authorize: {auth_response.url}"
174
+ auth_message = (
175
+ f"Please use the following link to authorize: {auth_response.url}"
176
+ )
165
177
  if langgraph:
166
178
  raise NodeInterrupt(auth_message)
167
179
  return {"error": auth_message}
@@ -249,10 +261,13 @@ def create_async_tool_function(
249
261
  An async callable function that executes the tool.
250
262
  """
251
263
  if langgraph and not LANGGRAPH_ENABLED:
252
- raise ImportError("LangGraph is not installed. Please install it to use this feature.")
264
+ raise ImportError(
265
+ "LangGraph is not installed. Please install it to use this feature."
266
+ )
253
267
 
254
268
  requires_authorization = (
255
- tool_def.requirements is not None and tool_def.requirements.authorization is not None
269
+ tool_def.requirements is not None
270
+ and tool_def.requirements.authorization is not None
256
271
  )
257
272
 
258
273
  async def tool_function(config: RunnableConfig, **kwargs: Any) -> Any:
@@ -275,9 +290,13 @@ def create_async_tool_function(
275
290
  return {"error": error_message}
276
291
 
277
292
  # Authorize the user for the tool
278
- auth_response = await client.tools.authorize(tool_name=tool_name, user_id=user_id)
293
+ auth_response = await client.tools.authorize(
294
+ tool_name=tool_name, user_id=user_id
295
+ )
279
296
  if auth_response.status != "completed":
280
- auth_message = f"Please use the following link to authorize: {auth_response.url}"
297
+ auth_message = (
298
+ f"Please use the following link to authorize: {auth_response.url}"
299
+ )
281
300
  if langgraph:
282
301
  raise NodeInterrupt(auth_message)
283
302
  return {"error": auth_message}
@@ -188,7 +188,9 @@ class ToolManager(LangChainToolManager):
188
188
  """
189
189
  tool_map = _create_tool_map(self.definitions, use_underscores=use_underscores)
190
190
  return [
191
- wrap_arcade_tool(self._client, tool_name, definition, langgraph=use_interrupts)
191
+ wrap_arcade_tool(
192
+ self._client, tool_name, definition, langgraph=use_interrupts
193
+ )
192
194
  for tool_name, definition in tool_map.items()
193
195
  ]
194
196
 
@@ -228,7 +230,9 @@ class ToolManager(LangChainToolManager):
228
230
  Raises:
229
231
  ValueError: If no tools or toolkits are provided and raise_on_empty is True.
230
232
  """
231
- tools_list = self._retrieve_tool_definitions(tools, toolkits, raise_on_empty, limit, offset)
233
+ tools_list = self._retrieve_tool_definitions(
234
+ tools, toolkits, raise_on_empty, limit, offset
235
+ )
232
236
  self._tools = _create_tool_map(tools_list)
233
237
  return self.to_langchain()
234
238
 
@@ -332,7 +336,9 @@ class ToolManager(LangChainToolManager):
332
336
  # If no specific tools or toolkits are requested, raise an error.
333
337
  if not tools and not toolkits:
334
338
  if raise_on_empty:
335
- raise ValueError("No tools or toolkits provided to retrieve tool definitions.")
339
+ raise ValueError(
340
+ "No tools or toolkits provided to retrieve tool definitions."
341
+ )
336
342
  return []
337
343
 
338
344
  # Retrieve individual tools if specified
@@ -378,7 +384,10 @@ class ToolManager(LangChainToolManager):
378
384
  self._tools.update(_create_tool_map([tool]))
379
385
 
380
386
  def add_toolkit(
381
- self, toolkit_name: str, limit: Optional[int] = None, offset: Optional[int] = None
387
+ self,
388
+ toolkit_name: str,
389
+ limit: Optional[int] = None,
390
+ offset: Optional[int] = None,
382
391
  ) -> None:
383
392
  """
384
393
  Add all tools from a specific toolkit to the manager.
@@ -584,7 +593,9 @@ class AsyncToolManager(LangChainToolManager):
584
593
  """
585
594
  tool_map = _create_tool_map(self.definitions, use_underscores=use_underscores)
586
595
  return [
587
- wrap_arcade_tool(self._client, tool_name, definition, langgraph=use_interrupts)
596
+ wrap_arcade_tool(
597
+ self._client, tool_name, definition, langgraph=use_interrupts
598
+ )
588
599
  for tool_name, definition in tool_map.items()
589
600
  ]
590
601
 
@@ -686,7 +697,9 @@ class AsyncToolManager(LangChainToolManager):
686
697
  # If no specific tools or toolkits are requested, raise an error.
687
698
  if not tools and not toolkits:
688
699
  if raise_on_empty:
689
- raise ValueError("No tools or toolkits provided to retrieve tool definitions.")
700
+ raise ValueError(
701
+ "No tools or toolkits provided to retrieve tool definitions."
702
+ )
690
703
  return []
691
704
 
692
705
  # First, gather single tools if the user specifically requested them.
@@ -734,7 +747,10 @@ class AsyncToolManager(LangChainToolManager):
734
747
  self._tools.update(_create_tool_map([tool]))
735
748
 
736
749
  async def add_toolkit(
737
- self, toolkit_name: str, limit: Optional[int] = None, offset: Optional[int] = None
750
+ self,
751
+ toolkit_name: str,
752
+ limit: Optional[int] = None,
753
+ offset: Optional[int] = None,
738
754
  ) -> None:
739
755
  """
740
756
  Add all tools from a specific toolkit to the manager.
@@ -1,21 +1,21 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: langchain-arcade
3
- Version: 1.3.0
3
+ Version: 1.4.4
4
4
  Summary: An integration package connecting Arcade and Langchain/LangGraph
5
- Home-page: https://github.com/arcadeai/arcade-ai/tree/main/contrib/langchain
6
- License: MIT
7
- Author: Arcade
8
- Author-email: dev@arcade.dev
9
- Requires-Python: >=3.10,<4
10
- Classifier: License :: OSI Approved :: MIT License
11
- Classifier: Programming Language :: Python :: 3
12
- Classifier: Programming Language :: Python :: 3.10
13
- Classifier: Programming Language :: Python :: 3.11
14
- Classifier: Programming Language :: Python :: 3.12
15
- Classifier: Programming Language :: Python :: 3.13
16
- Requires-Dist: arcadepy (==1.3.*)
17
- Requires-Dist: langgraph (>=0.2.67,<0.3.0)
18
- Project-URL: Repository, https://github.com/arcadeai/arcade-ai/tree/main/contrib/langchain
5
+ License-Expression: MIT
6
+ License-File: LICENSE
7
+ Requires-Python: >=3.10
8
+ Requires-Dist: arcadepy>=1.7.0
9
+ Requires-Dist: langchain-core<0.4,>=0.3.49
10
+ Provides-Extra: dev
11
+ Requires-Dist: langgraph<0.4,>=0.3.23; extra == 'dev'
12
+ Requires-Dist: mypy<1.6.0,>=1.5.1; extra == 'dev'
13
+ Requires-Dist: pre-commit<3.5.0,>=3.4.0; extra == 'dev'
14
+ Requires-Dist: pytest-asyncio<0.25.0,>=0.24.0; extra == 'dev'
15
+ Requires-Dist: pytest-cov<4.1.0,>=4.0.0; extra == 'dev'
16
+ Requires-Dist: pytest-mock<3.12.0,>=3.11.1; extra == 'dev'
17
+ Requires-Dist: pytest<8.4.0,>=8.3.0; extra == 'dev'
18
+ Requires-Dist: ruff<0.8.0,>=0.7.4; extra == 'dev'
19
19
  Description-Content-Type: text/markdown
20
20
 
21
21
  <h3 align="center">
@@ -80,6 +80,10 @@ langchain_tools = manager.to_langchain()
80
80
 
81
81
  ### 2. Use with LangGraph
82
82
 
83
+ ```bash
84
+ pip install langgraph
85
+ ```
86
+
83
87
  Here's a simple example of using Arcade tools with LangGraph:
84
88
 
85
89
  ```python
@@ -189,4 +193,3 @@ For a complete list, see the [Arcade Toolkits documentation](https://docs.arcade
189
193
  ## More Examples
190
194
 
191
195
  For more examples, see the [examples directory](https://github.com/ArcadeAI/arcade-ai/tree/main/examples/langchain).
192
-
@@ -0,0 +1,8 @@
1
+ langchain_arcade/__init__.py,sha256=8HcJ7Qss7QgaV7WQmk-tQdMcvV8cJhsMy3yUDE4hvik,167
2
+ langchain_arcade/_utilities.py,sha256=kxNT9_HizfkMjICLUbhoUG1xC3BYmZ76DoaSi44UbdM,10635
3
+ langchain_arcade/manager.py,sha256=3cQy4fIZ4AsEGpPfrl48zXbiEBulzbC5ZcbG9CeEfcg,32682
4
+ langchain_arcade/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ langchain_arcade-1.4.4.dist-info/METADATA,sha256=1xHa8Tqyk1uhfn_vRxhdcDViSvc80wQDguC3OSNgw8c,6550
6
+ langchain_arcade-1.4.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
7
+ langchain_arcade-1.4.4.dist-info/licenses/LICENSE,sha256=f4Q0XUZJ2MqZBO1XsqqHhuZfSs2ar1cZEJ45150zERo,1067
8
+ langchain_arcade-1.4.4.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.9.1
2
+ Generator: hatchling 1.27.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,8 +0,0 @@
1
- langchain_arcade/__init__.py,sha256=8HcJ7Qss7QgaV7WQmk-tQdMcvV8cJhsMy3yUDE4hvik,167
2
- langchain_arcade/_utilities.py,sha256=0h6gu695UnErj1K71gM67il63uYUeIlkJcrRLmozpiI,10379
3
- langchain_arcade/manager.py,sha256=KUAyQBPQe4iILveVlSTfU2DGHBt0ENW9NlOMTKyLo3o,32474
4
- langchain_arcade/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- langchain_arcade-1.3.0.dist-info/LICENSE,sha256=f4Q0XUZJ2MqZBO1XsqqHhuZfSs2ar1cZEJ45150zERo,1067
6
- langchain_arcade-1.3.0.dist-info/METADATA,sha256=p73fch-Cx7t90vnH0V95IrHb8iPS9lkRIQtDwQpXgw4,6545
7
- langchain_arcade-1.3.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
8
- langchain_arcade-1.3.0.dist-info/RECORD,,