langchain-arcade 1.4.4__tar.gz → 2.0.1__tar.gz
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.
- langchain_arcade-2.0.1/Makefile +4 -0
- langchain_arcade-2.0.1/PKG-INFO +54 -0
- langchain_arcade-2.0.1/README.md +34 -0
- langchain_arcade-2.0.1/langchain_arcade/__init__.py +17 -0
- langchain_arcade-2.0.1/pyproject.toml +30 -0
- langchain_arcade-1.4.4/Makefile +0 -47
- langchain_arcade-1.4.4/PKG-INFO +0 -195
- langchain_arcade-1.4.4/README.md +0 -175
- langchain_arcade-1.4.4/langchain_arcade/__init__.py +0 -7
- langchain_arcade-1.4.4/langchain_arcade/_utilities.py +0 -313
- langchain_arcade-1.4.4/langchain_arcade/manager.py +0 -848
- langchain_arcade-1.4.4/pyproject.toml +0 -59
- langchain_arcade-1.4.4/tests/conftest.py +0 -33
- langchain_arcade-1.4.4/tests/test_manager.py +0 -738
- langchain_arcade-1.4.4/tox.ini +0 -16
- {langchain_arcade-1.4.4 → langchain_arcade-2.0.1}/.gitignore +0 -0
- {langchain_arcade-1.4.4 → langchain_arcade-2.0.1}/LICENSE +0 -0
- {langchain_arcade-1.4.4 → langchain_arcade-2.0.1}/langchain_arcade/py.typed +0 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: langchain-arcade
|
|
3
|
+
Version: 2.0.1
|
|
4
|
+
Summary: This package is no longer maintained. Please visit https://docs.arcade.dev for the latest Arcade integrations.
|
|
5
|
+
Project-URL: Homepage, https://docs.arcade.dev
|
|
6
|
+
Project-URL: Documentation, https://docs.arcade.dev
|
|
7
|
+
Project-URL: Repository, https://github.com/arcadeai/arcade-mcp
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: arcade,deprecated,langchain
|
|
11
|
+
Classifier: Development Status :: 7 - Inactive
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Requires-Python: >=3.10
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
<h3 align="center">
|
|
22
|
+
<img
|
|
23
|
+
src="https://docs.arcade.dev/images/logo/arcade-logo.png"
|
|
24
|
+
>
|
|
25
|
+
</h3>
|
|
26
|
+
|
|
27
|
+
<div align="center">
|
|
28
|
+
<h1>⚠️ DEPRECATED ⚠️</h1>
|
|
29
|
+
<h3>langchain-arcade is no longer maintained</h3>
|
|
30
|
+
</div>
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Important Notice
|
|
35
|
+
|
|
36
|
+
**This package has been deprecated and is no longer maintained.**
|
|
37
|
+
|
|
38
|
+
The `langchain-arcade` package is no longer needed. Arcade now provides better ways to integrate with your AI applications.
|
|
39
|
+
|
|
40
|
+
## What Should I Use Instead?
|
|
41
|
+
|
|
42
|
+
Please visit **[docs.arcade.dev](https://docs.arcade.dev)** for the latest documentation on how to integrate Arcade tools into your applications.
|
|
43
|
+
|
|
44
|
+
## Migration Guide
|
|
45
|
+
|
|
46
|
+
If you were previously using `langchain-arcade`, we recommend:
|
|
47
|
+
|
|
48
|
+
1. Visit [docs.arcade.dev](https://docs.arcade.dev) to learn about the new integration options
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
<p align="center">
|
|
53
|
+
Thank you for using langchain-arcade. We hope to see you using Arcade's new integrations!
|
|
54
|
+
</p>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<h3 align="center">
|
|
2
|
+
<img
|
|
3
|
+
src="https://docs.arcade.dev/images/logo/arcade-logo.png"
|
|
4
|
+
>
|
|
5
|
+
</h3>
|
|
6
|
+
|
|
7
|
+
<div align="center">
|
|
8
|
+
<h1>⚠️ DEPRECATED ⚠️</h1>
|
|
9
|
+
<h3>langchain-arcade is no longer maintained</h3>
|
|
10
|
+
</div>
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Important Notice
|
|
15
|
+
|
|
16
|
+
**This package has been deprecated and is no longer maintained.**
|
|
17
|
+
|
|
18
|
+
The `langchain-arcade` package is no longer needed. Arcade now provides better ways to integrate with your AI applications.
|
|
19
|
+
|
|
20
|
+
## What Should I Use Instead?
|
|
21
|
+
|
|
22
|
+
Please visit **[docs.arcade.dev](https://docs.arcade.dev)** for the latest documentation on how to integrate Arcade tools into your applications.
|
|
23
|
+
|
|
24
|
+
## Migration Guide
|
|
25
|
+
|
|
26
|
+
If you were previously using `langchain-arcade`, we recommend:
|
|
27
|
+
|
|
28
|
+
1. Visit [docs.arcade.dev](https://docs.arcade.dev) to learn about the new integration options
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
<p align="center">
|
|
33
|
+
Thank you for using langchain-arcade. We hope to see you using Arcade's new integrations!
|
|
34
|
+
</p>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import warnings
|
|
2
|
+
|
|
3
|
+
warnings.warn(
|
|
4
|
+
"\n" + "=" * 70 + "\n"
|
|
5
|
+
"DEPRECATION NOTICE: langchain-arcade is no longer maintained.\n"
|
|
6
|
+
"\n"
|
|
7
|
+
"This package has been deprecated. Please visit https://docs.arcade.dev\n"
|
|
8
|
+
"for the latest documentation on integrating Arcade tools into your\n"
|
|
9
|
+
"applications.\n"
|
|
10
|
+
"\n"
|
|
11
|
+
"Arcade now supports MCP (Model Context Protocol) and direct API\n"
|
|
12
|
+
"integration via the Arcade Python SDK.\n" + "=" * 70,
|
|
13
|
+
DeprecationWarning,
|
|
14
|
+
stacklevel=2,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
__all__: list[str] = []
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = [ "hatchling",]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "langchain-arcade"
|
|
7
|
+
version = "2.0.1"
|
|
8
|
+
description = "This package is no longer maintained. Please visit https://docs.arcade.dev for the latest Arcade integrations."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
keywords = ["deprecated", "arcade", "langchain"]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Development Status :: 7 - Inactive",
|
|
15
|
+
"Intended Audience :: Developers",
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Programming Language :: Python :: 3.10",
|
|
19
|
+
"Programming Language :: Python :: 3.11",
|
|
20
|
+
"Programming Language :: Python :: 3.12",
|
|
21
|
+
]
|
|
22
|
+
dependencies = []
|
|
23
|
+
|
|
24
|
+
[project.urls]
|
|
25
|
+
Homepage = "https://docs.arcade.dev"
|
|
26
|
+
Documentation = "https://docs.arcade.dev"
|
|
27
|
+
Repository = "https://github.com/arcadeai/arcade-mcp"
|
|
28
|
+
|
|
29
|
+
[tool.hatch.build.targets.wheel]
|
|
30
|
+
packages = ["langchain_arcade"]
|
langchain_arcade-1.4.4/Makefile
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
.PHONY: help
|
|
2
|
-
|
|
3
|
-
help:
|
|
4
|
-
@echo "🛠️ github Commands:\n"
|
|
5
|
-
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
.PHONY: install
|
|
9
|
-
install: ## Install the uv environment and install all packages with dependencies
|
|
10
|
-
@echo "🚀 Creating virtual environment and installing all packages using uv"
|
|
11
|
-
@uv sync --active --all-extras --no-sources
|
|
12
|
-
@uv run pre-commit install
|
|
13
|
-
@echo "✅ All packages and dependencies installed via uv"
|
|
14
|
-
|
|
15
|
-
.PHONY: build
|
|
16
|
-
build: clean-build ## Build wheel file using uv
|
|
17
|
-
@echo "🚀 Creating wheel file"
|
|
18
|
-
uv build
|
|
19
|
-
|
|
20
|
-
.PHONY: clean-build
|
|
21
|
-
clean-build: ## clean build artifacts
|
|
22
|
-
@echo "🗑️ Cleaning dist directory"
|
|
23
|
-
rm -rf dist
|
|
24
|
-
|
|
25
|
-
.PHONY: test
|
|
26
|
-
test: ## Test the code with pytest
|
|
27
|
-
@echo "🚀 Testing code: Running pytest"
|
|
28
|
-
@uv run pytest -W ignore -v --cov --cov-config=pyproject.toml --cov-report=xml
|
|
29
|
-
|
|
30
|
-
.PHONY: coverage
|
|
31
|
-
coverage: ## Generate coverage report
|
|
32
|
-
@echo "coverage report"
|
|
33
|
-
coverage report
|
|
34
|
-
@echo "Generating coverage report"
|
|
35
|
-
coverage html
|
|
36
|
-
|
|
37
|
-
.PHONY: bump-version
|
|
38
|
-
bump-version: ## Bump the version in the pyproject.toml file by a patch version
|
|
39
|
-
@echo "🚀 Bumping version in pyproject.toml"
|
|
40
|
-
uv version --bump patch
|
|
41
|
-
|
|
42
|
-
.PHONY: check
|
|
43
|
-
check: ## Run code quality tools.
|
|
44
|
-
@echo "🚀 Linting code: Running pre-commit"
|
|
45
|
-
@uv run pre-commit run -a
|
|
46
|
-
@echo "🚀 Static type checking: Running mypy"
|
|
47
|
-
@uv run mypy --config-file=pyproject.toml
|
langchain_arcade-1.4.4/PKG-INFO
DELETED
|
@@ -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).
|
langchain_arcade-1.4.4/README.md
DELETED
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
<h3 align="center">
|
|
2
|
-
<a name="readme-top"></a>
|
|
3
|
-
<img
|
|
4
|
-
src="https://docs.arcade.dev/images/logo/arcade-logo.png"
|
|
5
|
-
>
|
|
6
|
-
</h3>
|
|
7
|
-
<div align="center">
|
|
8
|
-
<h3>Arcade Langchain Integration</h3>
|
|
9
|
-
<a href="https://github.com/arcadeai/langchain-arcade/blob/main/LICENSE">
|
|
10
|
-
<img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License">
|
|
11
|
-
</a>
|
|
12
|
-
<a href="https://pepy.tech/project/langchain-arcade">
|
|
13
|
-
<img src="https://static.pepy.tech/badge/langchain-arcade" alt="Downloads">
|
|
14
|
-
<a href="https://pypi.org/project/langchain-arcade/">
|
|
15
|
-
<img src="https://img.shields.io/pypi/v/langchain-arcade.svg" alt="PyPI">
|
|
16
|
-
</a>
|
|
17
|
-
</a>
|
|
18
|
-
|
|
19
|
-
</div>
|
|
20
|
-
|
|
21
|
-
<p align="center">
|
|
22
|
-
<a href="https://docs.arcade.dev" target="_blank">Arcade Documentation</a> •
|
|
23
|
-
<a href="https://docs.arcade.dev/toolkits" target="_blank">Toolkits</a> •
|
|
24
|
-
<a href="https://github.com/ArcadeAI/arcade-py" target="_blank">Python Client</a> •
|
|
25
|
-
<a href="https://github.com/ArcadeAI/arcade-js" target="_blank">JavaScript Client</a>
|
|
26
|
-
</p>
|
|
27
|
-
|
|
28
|
-
## Overview
|
|
29
|
-
|
|
30
|
-
`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.
|
|
31
|
-
|
|
32
|
-
## Installation
|
|
33
|
-
|
|
34
|
-
```bash
|
|
35
|
-
pip install langchain-arcade
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
## Basic Usage
|
|
39
|
-
|
|
40
|
-
### 1. Initialize the Tool Manager
|
|
41
|
-
|
|
42
|
-
The `ToolManager` is the main entry point for working with Arcade tools in LangChain:
|
|
43
|
-
|
|
44
|
-
```python
|
|
45
|
-
import os
|
|
46
|
-
from langchain_arcade import ToolManager
|
|
47
|
-
|
|
48
|
-
# Initialize with your API key
|
|
49
|
-
manager = ToolManager(api_key=os.environ["ARCADE_API_KEY"])
|
|
50
|
-
|
|
51
|
-
# Initialize with specific tools or toolkits
|
|
52
|
-
tools = manager.init_tools(
|
|
53
|
-
tools=["Web.ScrapeUrl"], # Individual tools
|
|
54
|
-
toolkits=["Search"] # All tools from a toolkit
|
|
55
|
-
)
|
|
56
|
-
|
|
57
|
-
# Convert to LangChain tools
|
|
58
|
-
langchain_tools = manager.to_langchain()
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
### 2. Use with LangGraph
|
|
62
|
-
|
|
63
|
-
```bash
|
|
64
|
-
pip install langgraph
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
Here's a simple example of using Arcade tools with LangGraph:
|
|
68
|
-
|
|
69
|
-
```python
|
|
70
|
-
from langchain_openai import ChatOpenAI
|
|
71
|
-
from langgraph.checkpoint.memory import MemorySaver
|
|
72
|
-
from langgraph.prebuilt import create_react_agent
|
|
73
|
-
|
|
74
|
-
# Create a LangGraph agent
|
|
75
|
-
model = ChatOpenAI(model="gpt-4o")
|
|
76
|
-
memory = MemorySaver()
|
|
77
|
-
graph = create_react_agent(model, tools, checkpointer=memory)
|
|
78
|
-
|
|
79
|
-
config = {"configurable": {"thread_id": "1", "user_id": "user@example.com"}}
|
|
80
|
-
user_input = {"messages": [("user", "List my important emails")]}
|
|
81
|
-
|
|
82
|
-
for chunk in graph.stream(user_input, config, stream_mode="values"):
|
|
83
|
-
print(chunk["messages"][-1].content)
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
## Using Tools with Authorization in LangGraph
|
|
87
|
-
|
|
88
|
-
Many Arcade tools require user authorization. Here's how to handle it:
|
|
89
|
-
|
|
90
|
-
### 1. Using with prebuilt agents
|
|
91
|
-
|
|
92
|
-
```python
|
|
93
|
-
import os
|
|
94
|
-
|
|
95
|
-
from langchain_arcade import ToolManager
|
|
96
|
-
from langchain_openai import ChatOpenAI
|
|
97
|
-
from langgraph.prebuilt import create_react_agent
|
|
98
|
-
|
|
99
|
-
# Initialize tools
|
|
100
|
-
manager = ToolManager(api_key=os.environ["ARCADE_API_KEY"])
|
|
101
|
-
manager.init_tools(toolkits=["Github"])
|
|
102
|
-
tools = manager.to_langchain(use_interrupts=True)
|
|
103
|
-
|
|
104
|
-
# Create agent
|
|
105
|
-
model = ChatOpenAI(model="gpt-4o")
|
|
106
|
-
graph = create_react_agent(model, tools)
|
|
107
|
-
|
|
108
|
-
# Run the agent with the "user_id" field in the config
|
|
109
|
-
# IMPORTANT the "user_id" field is required for tools that require user authorization
|
|
110
|
-
config = {"configurable": {"user_id": "user@lgexample.com"}}
|
|
111
|
-
user_input = {"messages": [("user", "Star the arcadeai/arcade-ai repository on GitHub")]}
|
|
112
|
-
|
|
113
|
-
for chunk in graph.stream(user_input, config, debug=True):
|
|
114
|
-
if chunk.get("__interrupt__"):
|
|
115
|
-
# print the authorization url
|
|
116
|
-
print(chunk["__interrupt__"][0].value)
|
|
117
|
-
# visit the URL to authorize the tool
|
|
118
|
-
# once you have authorized the tool, you can run again and the agent will continue
|
|
119
|
-
elif chunk.get("agent"):
|
|
120
|
-
print(chunk["agent"]["messages"][-1].content)
|
|
121
|
-
|
|
122
|
-
# see the functional example for continuing the agent after authorization
|
|
123
|
-
# and for handling authorization errors gracefully
|
|
124
|
-
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
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.
|
|
128
|
-
|
|
129
|
-
### Async Support
|
|
130
|
-
|
|
131
|
-
For asynchronous applications, use `AsyncToolManager`:
|
|
132
|
-
|
|
133
|
-
```python
|
|
134
|
-
import asyncio
|
|
135
|
-
from langchain_arcade import AsyncToolManager
|
|
136
|
-
|
|
137
|
-
async def main():
|
|
138
|
-
manager = AsyncToolManager(api_key=os.environ["ARCADE_API_KEY"])
|
|
139
|
-
await manager.init_tools(toolkits=["Google"])
|
|
140
|
-
tools = await manager.to_langchain()
|
|
141
|
-
|
|
142
|
-
# Use tools with async LangChain/LangGraph components
|
|
143
|
-
|
|
144
|
-
asyncio.run(main())
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
## Tool Authorization Flow
|
|
148
|
-
|
|
149
|
-
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:
|
|
150
|
-
|
|
151
|
-
1. Attempt to use a tool that requires authorization
|
|
152
|
-
2. Check the state for interrupts from the `NodeInterrupt` exception (or Command)
|
|
153
|
-
3. Call `manager.authorize(tool_name, user_id)` to get an authorization URL
|
|
154
|
-
4. Present the URL to the user
|
|
155
|
-
5. Call `manager.wait_for_auth(auth_response.id)` to wait for completion
|
|
156
|
-
6. Resume the agent execution
|
|
157
|
-
|
|
158
|
-
## Available Toolkits
|
|
159
|
-
|
|
160
|
-
Arcade provides many toolkits including:
|
|
161
|
-
|
|
162
|
-
- `Search`: Google search, Bing search
|
|
163
|
-
- `Google`: Gmail, Google Drive, Google Calendar
|
|
164
|
-
- `Web`: Crawling, scraping, etc
|
|
165
|
-
- `Github`: Repository operations
|
|
166
|
-
- `Slack`: Sending messages to Slack
|
|
167
|
-
- `Linkedin`: Posting to Linkedin
|
|
168
|
-
- `X`: Posting and reading tweets on X
|
|
169
|
-
- And many more
|
|
170
|
-
|
|
171
|
-
For a complete list, see the [Arcade Toolkits documentation](https://docs.arcade.dev/toolkits).
|
|
172
|
-
|
|
173
|
-
## More Examples
|
|
174
|
-
|
|
175
|
-
For more examples, see the [examples directory](https://github.com/ArcadeAI/arcade-ai/tree/main/examples/langchain).
|