This PR includes several improvements to the Arcade client and adds LangGraph examples: 1. Enhanced error handling in the Arcade client: - Improved HTTP error handling in `BaseArcadeClient` - Simplified request methods in `SyncArcadeClient` and `AsyncArcadeClient` 2. Updated `ToolResource` class: - Changed base path from `/v1/tool` to `/v1/tools` - Added `tool_version` parameter to `authorize` method 3. Improved Toolkit discovery: - Updated `find_all_arcade_toolkits` to search only in the current Python interpreter's site-packages 5. Added LangGraph examples: - New `langgraph_auth.py` example demonstrating Gmail authentication - New `langgraph_with_tool_exec.py` example showing tool execution within a LangGraph 6. Minor updates: - Changed default `BASE_URL` to `https://api.arcade.com/` - Updated import error message for eval dependencies --------- Co-authored-by: Nate Barbettini <nate@arcade-ai.com>
45 lines
1.3 KiB
Python
45 lines
1.3 KiB
Python
import os
|
|
|
|
from modal import App, Image, asgi_app
|
|
|
|
os.environ["ARCADE_WORK_DIR"] = "/root"
|
|
|
|
# Define the FastAPI app
|
|
app = App("arcade-ai-actor")
|
|
|
|
|
|
image = (
|
|
Image.debian_slim()
|
|
.copy_local_dir("./dist", "/root/dist")
|
|
.pip_install("/root/dist/arcade_ai-0.1.0-py3-none-any.whl")
|
|
.pip_install("/root/dist/arcade_gmail-0.1.0-py3-none-any.whl")
|
|
.pip_install("/root/dist/arcade_search-0.1.0-py3-none-any.whl")
|
|
.pip_install("/root/dist/arcade_slack-0.1.0-py3-none-any.whl")
|
|
.pip_install("/root/dist/arcade_x-0.1.0-py3-none-any.whl")
|
|
.pip_install("fastapi>=0.110.0")
|
|
.pip_install("uvicorn>=0.24.0")
|
|
.pip_install("pydantic>=2.7.0")
|
|
.copy_local_file("./arcade.toml", "/root/arcade.toml")
|
|
)
|
|
|
|
|
|
@app.function(image=image)
|
|
@asgi_app()
|
|
def fastapi_app():
|
|
from fastapi import FastAPI
|
|
|
|
from arcade.actor.fastapi.actor import FastAPIActor
|
|
from arcade.core.toolkit import Toolkit
|
|
|
|
web_app = FastAPI()
|
|
|
|
# Initialize app and Arcade FastAPIActor
|
|
actor_secret = os.environ.get("ARCADE_ACTOR_SECRET")
|
|
actor = FastAPIActor(web_app, secret=actor_secret)
|
|
|
|
# Register toolkits we've installed
|
|
toolkits = Toolkit.find_all_arcade_toolkits()
|
|
for toolkit in toolkits:
|
|
actor.register_toolkit(toolkit)
|
|
|
|
return web_app
|