langchain-arcade 1.4.4__py3-none-any.whl → 2.0.1__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.
@@ -1,195 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: langchain-arcade
3
- Version: 1.4.4
4
- Summary: An integration package connecting Arcade and Langchain/LangGraph
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
- 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
- ```bash
84
- pip install langgraph
85
- ```
86
-
87
- Here's a simple example of using Arcade tools with LangGraph:
88
-
89
- ```python
90
- from langchain_openai import ChatOpenAI
91
- from langgraph.checkpoint.memory import MemorySaver
92
- from langgraph.prebuilt import create_react_agent
93
-
94
- # Create a LangGraph agent
95
- model = ChatOpenAI(model="gpt-4o")
96
- memory = MemorySaver()
97
- graph = create_react_agent(model, tools, checkpointer=memory)
98
-
99
- config = {"configurable": {"thread_id": "1", "user_id": "user@example.com"}}
100
- user_input = {"messages": [("user", "List my important emails")]}
101
-
102
- for chunk in graph.stream(user_input, config, stream_mode="values"):
103
- print(chunk["messages"][-1].content)
104
- ```
105
-
106
- ## Using Tools with Authorization in LangGraph
107
-
108
- Many Arcade tools require user authorization. Here's how to handle it:
109
-
110
- ### 1. Using with prebuilt agents
111
-
112
- ```python
113
- import os
114
-
115
- from langchain_arcade import ToolManager
116
- from langchain_openai import ChatOpenAI
117
- from langgraph.prebuilt import create_react_agent
118
-
119
- # Initialize tools
120
- manager = ToolManager(api_key=os.environ["ARCADE_API_KEY"])
121
- manager.init_tools(toolkits=["Github"])
122
- tools = manager.to_langchain(use_interrupts=True)
123
-
124
- # Create agent
125
- model = ChatOpenAI(model="gpt-4o")
126
- graph = create_react_agent(model, tools)
127
-
128
- # Run the agent with the "user_id" field in the config
129
- # IMPORTANT the "user_id" field is required for tools that require user authorization
130
- config = {"configurable": {"user_id": "user@lgexample.com"}}
131
- user_input = {"messages": [("user", "Star the arcadeai/arcade-ai repository on GitHub")]}
132
-
133
- for chunk in graph.stream(user_input, config, debug=True):
134
- if chunk.get("__interrupt__"):
135
- # print the authorization url
136
- print(chunk["__interrupt__"][0].value)
137
- # visit the URL to authorize the tool
138
- # once you have authorized the tool, you can run again and the agent will continue
139
- elif chunk.get("agent"):
140
- print(chunk["agent"]["messages"][-1].content)
141
-
142
- # see the functional example for continuing the agent after authorization
143
- # and for handling authorization errors gracefully
144
-
145
- ```
146
-
147
- 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.
148
-
149
- ### Async Support
150
-
151
- For asynchronous applications, use `AsyncToolManager`:
152
-
153
- ```python
154
- import asyncio
155
- from langchain_arcade import AsyncToolManager
156
-
157
- async def main():
158
- manager = AsyncToolManager(api_key=os.environ["ARCADE_API_KEY"])
159
- await manager.init_tools(toolkits=["Google"])
160
- tools = await manager.to_langchain()
161
-
162
- # Use tools with async LangChain/LangGraph components
163
-
164
- asyncio.run(main())
165
- ```
166
-
167
- ## Tool Authorization Flow
168
-
169
- 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:
170
-
171
- 1. Attempt to use a tool that requires authorization
172
- 2. Check the state for interrupts from the `NodeInterrupt` exception (or Command)
173
- 3. Call `manager.authorize(tool_name, user_id)` to get an authorization URL
174
- 4. Present the URL to the user
175
- 5. Call `manager.wait_for_auth(auth_response.id)` to wait for completion
176
- 6. Resume the agent execution
177
-
178
- ## Available Toolkits
179
-
180
- Arcade provides many toolkits including:
181
-
182
- - `Search`: Google search, Bing search
183
- - `Google`: Gmail, Google Drive, Google Calendar
184
- - `Web`: Crawling, scraping, etc
185
- - `Github`: Repository operations
186
- - `Slack`: Sending messages to Slack
187
- - `Linkedin`: Posting to Linkedin
188
- - `X`: Posting and reading tweets on X
189
- - And many more
190
-
191
- For a complete list, see the [Arcade Toolkits documentation](https://docs.arcade.dev/toolkits).
192
-
193
- ## More Examples
194
-
195
- For more examples, see the [examples directory](https://github.com/ArcadeAI/arcade-ai/tree/main/examples/langchain).
@@ -1,8 +0,0 @@
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,,