langchain-arcade 1.3.1__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/.gitignore +175 -0
- 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.3.1/PKG-INFO +0 -196
- langchain_arcade-1.3.1/README.md +0 -175
- langchain_arcade-1.3.1/langchain_arcade/__init__.py +0 -7
- langchain_arcade-1.3.1/langchain_arcade/_utilities.py +0 -294
- langchain_arcade-1.3.1/langchain_arcade/manager.py +0 -832
- langchain_arcade-1.3.1/pyproject.toml +0 -47
- {langchain_arcade-1.3.1 → langchain_arcade-2.0.1}/LICENSE +0 -0
- {langchain_arcade-1.3.1 → langchain_arcade-2.0.1}/langchain_arcade/py.typed +0 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
.DS_Store
|
|
2
|
+
credentials.yaml
|
|
3
|
+
docker/credentials.yaml
|
|
4
|
+
|
|
5
|
+
*.lock
|
|
6
|
+
|
|
7
|
+
# example data
|
|
8
|
+
examples/data
|
|
9
|
+
scratch
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
docs/source
|
|
13
|
+
|
|
14
|
+
# From https://raw.githubusercontent.com/github/gitignore/main/Python.gitignore
|
|
15
|
+
|
|
16
|
+
# Byte-compiled / optimized / DLL files
|
|
17
|
+
__pycache__/
|
|
18
|
+
*.py[cod]
|
|
19
|
+
*$py.class
|
|
20
|
+
|
|
21
|
+
# C extensions
|
|
22
|
+
*.so
|
|
23
|
+
|
|
24
|
+
# Distribution / packaging
|
|
25
|
+
.Python
|
|
26
|
+
build/
|
|
27
|
+
develop-eggs/
|
|
28
|
+
dist/
|
|
29
|
+
downloads/
|
|
30
|
+
eggs/
|
|
31
|
+
.eggs/
|
|
32
|
+
lib/
|
|
33
|
+
lib64/
|
|
34
|
+
parts/
|
|
35
|
+
sdist/
|
|
36
|
+
var/
|
|
37
|
+
wheels/
|
|
38
|
+
share/python-wheels/
|
|
39
|
+
*.egg-info/
|
|
40
|
+
.installed.cfg
|
|
41
|
+
*.egg
|
|
42
|
+
MANIFEST
|
|
43
|
+
|
|
44
|
+
# PyInstaller
|
|
45
|
+
# Usually these files are written by a python script from a template
|
|
46
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
47
|
+
*.manifest
|
|
48
|
+
*.spec
|
|
49
|
+
|
|
50
|
+
# Installer logs
|
|
51
|
+
pip-log.txt
|
|
52
|
+
pip-delete-this-directory.txt
|
|
53
|
+
|
|
54
|
+
# Unit test / coverage reports
|
|
55
|
+
htmlcov/
|
|
56
|
+
.tox/
|
|
57
|
+
.nox/
|
|
58
|
+
.coverage
|
|
59
|
+
.coverage.*
|
|
60
|
+
.cache
|
|
61
|
+
nosetests.xml
|
|
62
|
+
coverage.xml
|
|
63
|
+
*.cover
|
|
64
|
+
*.py,cover
|
|
65
|
+
.hypothesis/
|
|
66
|
+
.pytest_cache/
|
|
67
|
+
cover/
|
|
68
|
+
|
|
69
|
+
# Translations
|
|
70
|
+
*.mo
|
|
71
|
+
*.pot
|
|
72
|
+
|
|
73
|
+
# Django stuff:
|
|
74
|
+
*.log
|
|
75
|
+
local_settings.py
|
|
76
|
+
db.sqlite3
|
|
77
|
+
db.sqlite3-journal
|
|
78
|
+
|
|
79
|
+
# Flask stuff:
|
|
80
|
+
instance/
|
|
81
|
+
.webassets-cache
|
|
82
|
+
|
|
83
|
+
# Scrapy stuff:
|
|
84
|
+
.scrapy
|
|
85
|
+
|
|
86
|
+
# Sphinx documentation
|
|
87
|
+
docs/_build/
|
|
88
|
+
|
|
89
|
+
# PyBuilder
|
|
90
|
+
.pybuilder/
|
|
91
|
+
target/
|
|
92
|
+
|
|
93
|
+
# Jupyter Notebook
|
|
94
|
+
.ipynb_checkpoints
|
|
95
|
+
|
|
96
|
+
# IPython
|
|
97
|
+
profile_default/
|
|
98
|
+
ipython_config.py
|
|
99
|
+
|
|
100
|
+
# pyenv
|
|
101
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
102
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
103
|
+
# .python-version
|
|
104
|
+
|
|
105
|
+
# pipenv
|
|
106
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
107
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
108
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
109
|
+
# install all needed dependencies.
|
|
110
|
+
#Pipfile.lock
|
|
111
|
+
|
|
112
|
+
# poetry
|
|
113
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
114
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
115
|
+
# commonly ignored for libraries.
|
|
116
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
117
|
+
poetry.lock
|
|
118
|
+
|
|
119
|
+
# pdm
|
|
120
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
121
|
+
#pdm.lock
|
|
122
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
123
|
+
# in version control.
|
|
124
|
+
# https://pdm.fming.dev/#use-with-ide
|
|
125
|
+
.pdm.toml
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# SageMath parsed files
|
|
135
|
+
*.sage.py
|
|
136
|
+
|
|
137
|
+
# Environments
|
|
138
|
+
.env
|
|
139
|
+
.venv
|
|
140
|
+
env/
|
|
141
|
+
venv/
|
|
142
|
+
ENV/
|
|
143
|
+
env.bak/
|
|
144
|
+
venv.bak/
|
|
145
|
+
|
|
146
|
+
# Spyder project settings
|
|
147
|
+
.spyderproject
|
|
148
|
+
.spyproject
|
|
149
|
+
|
|
150
|
+
# Rope project settings
|
|
151
|
+
.ropeproject
|
|
152
|
+
|
|
153
|
+
# mkdocs documentation
|
|
154
|
+
/site
|
|
155
|
+
|
|
156
|
+
# mypy
|
|
157
|
+
.mypy_cache/
|
|
158
|
+
.dmypy.json
|
|
159
|
+
dmypy.json
|
|
160
|
+
|
|
161
|
+
# Pyre type checker
|
|
162
|
+
.pyre/
|
|
163
|
+
|
|
164
|
+
# pytype static type analyzer
|
|
165
|
+
.pytype/
|
|
166
|
+
|
|
167
|
+
# Cython debug symbols
|
|
168
|
+
cython_debug/
|
|
169
|
+
|
|
170
|
+
# PyCharm
|
|
171
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
172
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
173
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
174
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
175
|
+
#.idea/
|
|
@@ -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.3.1/PKG-INFO
DELETED
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: langchain-arcade
|
|
3
|
-
Version: 1.3.1
|
|
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: langchain-core (>=0.3.49,<0.4)
|
|
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
|
-
```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).
|
|
196
|
-
|
langchain_arcade-1.3.1/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).
|