langchain-arcade 1.0.0__py3-none-any.whl → 1.2.0__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.
@@ -0,0 +1,192 @@
1
+ Metadata-Version: 2.1
2
+ Name: langchain-arcade
3
+ Version: 1.2.0
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.1.*)
17
+ Requires-Dist: langgraph (>=0.2.67,<0.3.0)
18
+ Project-URL: Repository, https://github.com/arcadeai/arcade-ai/tree/main/contrib/langchain
19
+ Description-Content-Type: text/markdown
20
+
21
+ <h3 align="center">
22
+ <a name="readme-top"></a>
23
+ <img
24
+ src="https://docs.arcade.dev/images/logo/arcade-logo.png"
25
+ >
26
+ </h3>
27
+ <div align="center">
28
+ <h3>Arcade Langchain Integration</h3>
29
+ <a href="https://github.com/arcadeai/langchain-arcade/blob/main/LICENSE">
30
+ <img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License">
31
+ </a>
32
+ <a href="https://pepy.tech/project/langchain-arcade">
33
+ <img src="https://static.pepy.tech/badge/langchain-arcade" alt="Downloads">
34
+ <a href="https://pypi.org/project/langchain-arcade/">
35
+ <img src="https://img.shields.io/pypi/v/langchain-arcade.svg" alt="PyPI">
36
+ </a>
37
+ </a>
38
+
39
+ </div>
40
+
41
+ <p align="center">
42
+ <a href="https://docs.arcade.dev" target="_blank">Arcade Documentation</a> •
43
+ <a href="https://docs.arcade.dev/toolkits" target="_blank">Toolkits</a> •
44
+ <a href="https://github.com/ArcadeAI/arcade-py" target="_blank">Python Client</a> •
45
+ <a href="https://github.com/ArcadeAI/arcade-js" target="_blank">JavaScript Client</a>
46
+ </p>
47
+
48
+ ## Overview
49
+
50
+ `langchain-arcade` allows you to use Arcade tools in your LangChain and LangGraph applications. This integration provides a simple way to access Arcade's extensive toolkit ecosystem, including tools for search, email, document processing, and more.
51
+
52
+ ## Installation
53
+
54
+ ```bash
55
+ pip install langchain-arcade
56
+ ```
57
+
58
+ ## Basic Usage
59
+
60
+ ### 1. Initialize the Tool Manager
61
+
62
+ The `ToolManager` is the main entry point for working with Arcade tools in LangChain:
63
+
64
+ ```python
65
+ import os
66
+ from langchain_arcade import ToolManager
67
+
68
+ # Initialize with your API key
69
+ manager = ToolManager(api_key=os.environ["ARCADE_API_KEY"])
70
+
71
+ # Initialize with specific tools or toolkits
72
+ tools = manager.init_tools(
73
+ tools=["Web.ScrapeUrl"], # Individual tools
74
+ toolkits=["Search"] # All tools from a toolkit
75
+ )
76
+
77
+ # Convert to LangChain tools
78
+ langchain_tools = manager.to_langchain()
79
+ ```
80
+
81
+ ### 2. Use with LangGraph
82
+
83
+ Here's a simple example of using Arcade tools with LangGraph:
84
+
85
+ ```python
86
+ from langchain_openai import ChatOpenAI
87
+ from langgraph.checkpoint.memory import MemorySaver
88
+ from langgraph.prebuilt import create_react_agent
89
+
90
+ # Create a LangGraph agent
91
+ model = ChatOpenAI(model="gpt-4o")
92
+ memory = MemorySaver()
93
+ graph = create_react_agent(model, tools, checkpointer=memory)
94
+
95
+ config = {"configurable": {"thread_id": "1", "user_id": "user@example.com"}}
96
+ user_input = {"messages": [("user", "List my important emails")]}
97
+
98
+ for chunk in graph.stream(user_input, config, stream_mode="values"):
99
+ print(chunk["messages"][-1].content)
100
+ ```
101
+
102
+ ## Using Tools with Authorization in LangGraph
103
+
104
+ Many Arcade tools require user authorization. Here's how to handle it:
105
+
106
+ ### 1. Using with prebuilt agents
107
+
108
+ ```python
109
+ import os
110
+
111
+ from langchain_arcade import ToolManager
112
+ from langchain_openai import ChatOpenAI
113
+ from langgraph.prebuilt import create_react_agent
114
+
115
+ # Initialize tools
116
+ manager = ToolManager(api_key=os.environ["ARCADE_API_KEY"])
117
+ manager.init_tools(toolkits=["Github"])
118
+ tools = manager.to_langchain(use_interrupts=True)
119
+
120
+ # Create agent
121
+ model = ChatOpenAI(model="gpt-4o")
122
+ graph = create_react_agent(model, tools)
123
+
124
+ # Run the agent with the "user_id" field in the config
125
+ # IMPORTANT the "user_id" field is required for tools that require user authorization
126
+ config = {"configurable": {"user_id": "user@lgexample.com"}}
127
+ user_input = {"messages": [("user", "Star the arcadeai/arcade-ai repository on GitHub")]}
128
+
129
+ for chunk in graph.stream(user_input, config, debug=True):
130
+ if chunk.get("__interrupt__"):
131
+ # print the authorization url
132
+ print(chunk["__interrupt__"][0].value)
133
+ # visit the URL to authorize the tool
134
+ # once you have authorized the tool, you can run again and the agent will continue
135
+ elif chunk.get("agent"):
136
+ print(chunk["agent"]["messages"][-1].content)
137
+
138
+ # see the functional example for continuing the agent after authorization
139
+ # and for handling authorization errors gracefully
140
+
141
+ ```
142
+
143
+ See the Functional examples in the [examples directory](https://github.com/ArcadeAI/arcade-ai/tree/main/examples/langchain) that continue the agent after authorization and handle authorization errors gracefully.
144
+
145
+ ### Async Support
146
+
147
+ For asynchronous applications, use `AsyncToolManager`:
148
+
149
+ ```python
150
+ import asyncio
151
+ from langchain_arcade import AsyncToolManager
152
+
153
+ async def main():
154
+ manager = AsyncToolManager(api_key=os.environ["ARCADE_API_KEY"])
155
+ await manager.init_tools(toolkits=["Google"])
156
+ tools = await manager.to_langchain()
157
+
158
+ # Use tools with async LangChain/LangGraph components
159
+
160
+ asyncio.run(main())
161
+ ```
162
+
163
+ ## Tool Authorization Flow
164
+
165
+ Many Arcade tools require user authorization. This can be handled in many ways but the `ToolManager` provides a simple flow that can be used with prebuilt agents and also the functional API. The typical flow is:
166
+
167
+ 1. Attempt to use a tool that requires authorization
168
+ 2. Check the state for interrupts from the `NodeInterrupt` exception (or Command)
169
+ 3. Call `manager.authorize(tool_name, user_id)` to get an authorization URL
170
+ 4. Present the URL to the user
171
+ 5. Call `manager.wait_for_auth(auth_response.id)` to wait for completion
172
+ 6. Resume the agent execution
173
+
174
+ ## Available Toolkits
175
+
176
+ Arcade provides many toolkits including:
177
+
178
+ - `Search`: Google search, Bing search
179
+ - `Google`: Gmail, Google Drive, Google Calendar
180
+ - `Web`: Crawling, scraping, etc
181
+ - `Github`: Repository operations
182
+ - `Slack`: Sending messages to Slack
183
+ - `Linkedin`: Posting to Linkedin
184
+ - `X`: Posting and reading tweets on X
185
+ - And many more
186
+
187
+ For a complete list, see the [Arcade Toolkits documentation](https://docs.arcade.dev/toolkits).
188
+
189
+ ## More Examples
190
+
191
+ 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=0h6gu695UnErj1K71gM67il63uYUeIlkJcrRLmozpiI,10379
3
+ langchain_arcade/manager.py,sha256=KUAyQBPQe4iILveVlSTfU2DGHBt0ENW9NlOMTKyLo3o,32474
4
+ langchain_arcade/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ langchain_arcade-1.2.0.dist-info/LICENSE,sha256=f4Q0XUZJ2MqZBO1XsqqHhuZfSs2ar1cZEJ45150zERo,1067
6
+ langchain_arcade-1.2.0.dist-info/METADATA,sha256=LpVxjv-r1n5LLgpDYE6PCJ1BTsYOMIvBTVZAWer8cKw,6545
7
+ langchain_arcade-1.2.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
8
+ langchain_arcade-1.2.0.dist-info/RECORD,,
@@ -1,58 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: langchain-arcade
3
- Version: 1.0.0
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 AI
8
- Author-email: dev@arcade-ai.com
9
- Requires-Python: >=3.10,<3.13
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
- Requires-Dist: arcadepy (>=1.0.0,<2.0.0)
16
- Requires-Dist: langgraph (>=0.2.67,<0.3.0)
17
- Project-URL: Repository, https://github.com/arcadeai/arcade-ai/tree/main/contrib/langchain
18
- Description-Content-Type: text/markdown
19
-
20
- <h3 align="center">
21
- <a name="readme-top"></a>
22
- <img
23
- src="https://docs.arcade-ai.com/images/logo/arcade-ai-logo.png"
24
- >
25
- </h3>
26
- <div align="center">
27
- <h3>LangChain Integration</h3>
28
- <a href="https://github.com/arcadeai/arcade-ai/blob/main/LICENSE">
29
- <img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License">
30
- </a>
31
- <a href="https://pepy.tech/project/langchain-arcade">
32
- <img src="https://static.pepy.tech/badge/langchain-arcade" alt="Downloads">
33
- </a>
34
-
35
- </div>
36
-
37
- <p align="center">
38
- <a href="https://docs.arcade-ai.com" target="_blank">Docs</a> •
39
- <a href="https://docs.arcade-ai.com/integrations" target="_blank">Integrations</a> •
40
- <a href="https://github.com/ArcadeAI/cookbook" target="_blank">Cookbook</a> •
41
- <a href="https://github.com/ArcadeAI/arcade-py" target="_blank">Python Client</a> •
42
- <a href="https://github.com/ArcadeAI/arcade-js" target="_blank">JavaScript Client</a>
43
- </p>
44
-
45
- ## Overview
46
-
47
- `langchain-arcade` allows you to use Arcade AI tools in your LangChain and LangGraph applications.
48
-
49
- ## Installation
50
-
51
- ```bash
52
- pip install langchain-arcade
53
- ```
54
-
55
- ## Usage
56
-
57
- See the [examples](https://github.com/ArcadeAI/arcade-ai/tree/main/examples/langchain) for usage examples
58
-
@@ -1,8 +0,0 @@
1
- langchain_arcade/__init__.py,sha256=nYAKEQBNNacNjGU6r_UY3lpkNzurGdujh2AsmdOky78,72
2
- langchain_arcade/_utilities.py,sha256=LvT3kYS1urBftixyzOlQbzYsBQC5zn8_VE9xkIxCfRY,5946
3
- langchain_arcade/manager.py,sha256=eTPeAxT7s2vBOio6Pik8hjXvsVIrFlNvM4M2MoQFSyA,8222
4
- langchain_arcade/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- langchain_arcade-1.0.0.dist-info/LICENSE,sha256=f4Q0XUZJ2MqZBO1XsqqHhuZfSs2ar1cZEJ45150zERo,1067
6
- langchain_arcade-1.0.0.dist-info/METADATA,sha256=RWHefz0bobB_gzCYxXP41cDGAphijosVV1CIdIFX_CQ,2004
7
- langchain_arcade-1.0.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
8
- langchain_arcade-1.0.0.dist-info/RECORD,,