Update Examples & Various Renames (#233)
# PR Description * This PR updates code in `examples/` to be compatible with version 1.0.0 * This PR removes the Spotify examples since the Arcade hosted worker doesn't currently cataloge the Spotify toolkit. We can reintroduce these examples when it does. * This PR performs various renames across the codebase for `arcade-ai.com` --> `arcade.dev` and `Arcade AI` --> `Arcade`
This commit is contained in:
parent
8226cb3316
commit
ce2fb0f6c1
33 changed files with 64 additions and 257 deletions
|
|
@ -29,7 +29,7 @@ Anything tagged with "enhancement" and "help wanted" is open to whoever wants to
|
||||||
|
|
||||||
## Write Documentation
|
## Write Documentation
|
||||||
|
|
||||||
Arcade AI could always use more documentation, whether as part of the official docs, in docstrings, or even on the web in blog posts, articles, and such.
|
Arcade could always use more documentation, whether as part of the official docs, in docstrings, or even on the web in blog posts, articles, and such.
|
||||||
|
|
||||||
## Submit Feedback
|
## Submit Feedback
|
||||||
|
|
||||||
|
|
|
||||||
2
Makefile
2
Makefile
|
|
@ -157,7 +157,7 @@ clean-dist: ## Clean all built distributions
|
||||||
|
|
||||||
.PHONY: help
|
.PHONY: help
|
||||||
help:
|
help:
|
||||||
@echo "🛠️ Arcade AI Dev Commands:\n"
|
@echo "🛠️ Arcade Dev Commands:\n"
|
||||||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
18
README.md
18
README.md
|
|
@ -43,7 +43,7 @@
|
||||||
|
|
||||||
[Arcade](https://arcade.dev?ref=github) provides developer-focused tooling and APIs designed to improve the capabilities of LLM applications and agents.
|
[Arcade](https://arcade.dev?ref=github) provides developer-focused tooling and APIs designed to improve the capabilities of LLM applications and agents.
|
||||||
|
|
||||||
By removing the complexity of connecting agentic applications with your users' data and services, Arcade AI enables developers to focus on building their agentic applications.
|
By removing the complexity of connecting agentic applications with your users' data and services, Arcade enables developers to focus on building their agentic applications.
|
||||||
|
|
||||||
To learn more, check out our [documentation](https://docs.arcade.dev/home).
|
To learn more, check out our [documentation](https://docs.arcade.dev/home).
|
||||||
|
|
||||||
|
|
@ -57,7 +57,7 @@ _Pst. hey, you, give us a star if you like it!_
|
||||||
|
|
||||||
### Requirements
|
### Requirements
|
||||||
|
|
||||||
1. An **[Arcade AI account](https://arcade-ai.typeform.com/early-access)** (currently a waitlist)
|
1. An **[Arcade account]([https://arcade-ai.typeform.com/early-access](https://account.arcade.dev/registerOrRedirect?return_to=https%3A%2F%2Fapi.arcade.dev%2Fdashboard&new_user_return_to=https%3A%2F%2Fapi.arcade.dev%2Fdashboard%2Fwelcome))**
|
||||||
2. **Python 3.10+** and **pip**
|
2. **Python 3.10+** and **pip**
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
|
|
@ -68,7 +68,7 @@ Install the package:
|
||||||
pip install 'arcade-ai[fastapi]'
|
pip install 'arcade-ai[fastapi]'
|
||||||
```
|
```
|
||||||
|
|
||||||
Log in to your account:
|
Log in to your account via the CLI:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
arcade login
|
arcade login
|
||||||
|
|
@ -93,7 +93,7 @@ User (dev@arcade.dev):
|
||||||
> star the ArcadeAI/arcade-ai repo on Github
|
> star the ArcadeAI/arcade-ai repo on Github
|
||||||
```
|
```
|
||||||
|
|
||||||
Arcade AI will prompt you to authorize with GitHub and will star the [ArcadeAI/arcade-ai](https://github.com/ArcadeAI/arcade-ai) repo on your behalf.
|
Arcade will prompt you to authorize with GitHub and will star the [ArcadeAI/arcade-ai](https://github.com/ArcadeAI/arcade-ai) repo on your behalf.
|
||||||
|
|
||||||
You'll see:
|
You'll see:
|
||||||
|
|
||||||
|
|
@ -106,11 +106,11 @@ Press `Ctrl-C` to exit the chat.
|
||||||
|
|
||||||
## Arcade Cloud
|
## Arcade Cloud
|
||||||
|
|
||||||
Arcade Cloud is a hosted version of the Arcade AI engine that hosts a number of prebuilt toolkits for interacting with a variety of services.
|
Arcade Cloud is a hosted version of the Arcade engine that hosts a number of prebuilt toolkits for interacting with a variety of services.
|
||||||
|
|
||||||
### Prebuilt Toolkits
|
### Prebuilt Toolkits
|
||||||
|
|
||||||
Arcade AI offers a number of prebuilt toolkits that can be used by agents to interact with a variety of services.
|
Arcade offers a number of prebuilt toolkits that can be used by agents to interact with a variety of services.
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
|
|
@ -300,13 +300,17 @@ The LLM API supports a variety of language models. Currently, the ones supported
|
||||||
|
|
||||||
For more information, refer to the [supported models documentation](https://docs.arcade.dev/home/supported-models).
|
For more information, refer to the [supported models documentation](https://docs.arcade.dev/home/supported-models).
|
||||||
|
|
||||||
|
### Get Started with Arcade
|
||||||
|
|
||||||
|
To get started with Arcade, check out our [quickstart guide](https://docs.arcade.dev/home/quickstart).
|
||||||
|
|
||||||
### Building Your Own Tools
|
### Building Your Own Tools
|
||||||
|
|
||||||
Learn how to build your own tools by following our [creating a custom toolkit guide](https://docs.arcade.dev/home/build-tools/create-a-toolkit).
|
Learn how to build your own tools by following our [creating a custom toolkit guide](https://docs.arcade.dev/home/build-tools/create-a-toolkit).
|
||||||
|
|
||||||
### Evaluating Tools
|
### Evaluating Tools
|
||||||
|
|
||||||
Arcade AI enables you to evaluate your custom tools to ensure they function correctly with the AI assistant, including defining evaluation cases and using different critics.
|
Arcade enables you to evaluate your custom tools to ensure they function correctly with the AI assistant, including defining evaluation cases and using different critics.
|
||||||
|
|
||||||
Learn how to evaluate your tools by following our [evaluating tools guide](https://docs.arcade.dev/home/evaluate-tools/create-an-evaluation-suite).
|
Learn how to evaluate your tools by following our [evaluating tools guide](https://docs.arcade.dev/home/evaluate-tools/create-an-evaluation-suite).
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
# Arcade AI Python SDK and CLI
|
# Arcade Python SDK and CLI
|
||||||
|
|
||||||
[Arcade AI](https://arcade-ai.com?ref=pypi) provides developer-focused tooling and APIs designed to improve the capabilities of LLM applications and agents.
|
[Arcade](https://arcade.dev?ref=pypi) provides developer-focused tooling and APIs designed to improve the capabilities of LLM applications and agents.
|
||||||
|
|
||||||
By removing the complexity of connecting agentic applications with your users' data and services, Arcade AI enables developers to focus on building their agentic applications.
|
By removing the complexity of connecting agentic applications with your users' data and services, Arcade enables developers to focus on building their agentic applications.
|
||||||
|
|
||||||
To learn more, check out our
|
To learn more, check out our
|
||||||
- [Website](https://arcade-ai.com?ref=pypi)
|
- [Website](https://arcade.dev?ref=pypi)
|
||||||
- [GitHub](https://github.com/ArcadeAI/arcade-ai)
|
- [GitHub](https://github.com/ArcadeAI/arcade-ai)
|
||||||
- [Documentation](https://docs.arcade-ai.com)
|
- [Documentation](https://docs.arcade.dev)
|
||||||
- [Discord](https://discord.com/invite/GUZEMpEZ9p)
|
- [Discord](https://discord.com/invite/GUZEMpEZ9p)
|
||||||
- [X](https://x.com/TryArcade)
|
- [X](https://x.com/TryArcade)
|
||||||
- [LinkedIn](https://www.linkedin.com/company/arcade-ai)
|
- [LinkedIn](https://www.linkedin.com/company/arcade-ai)
|
||||||
|
|
|
||||||
|
|
@ -227,7 +227,7 @@ def display_arcade_chat_header(base_url: str, stream: bool) -> None:
|
||||||
chat_header = Text.assemble(
|
chat_header = Text.assemble(
|
||||||
"\n",
|
"\n",
|
||||||
(
|
(
|
||||||
"=== Arcade AI Chat ===",
|
"=== Arcade Chat ===",
|
||||||
"bold magenta underline",
|
"bold magenta underline",
|
||||||
),
|
),
|
||||||
"\n",
|
"\n",
|
||||||
|
|
|
||||||
|
|
@ -169,7 +169,7 @@ def _get_config_file(
|
||||||
)
|
)
|
||||||
console.print(
|
console.print(
|
||||||
"TIP: Please install the Arcade Engine by following the instructions at:\n"
|
"TIP: Please install the Arcade Engine by following the instructions at:\n"
|
||||||
" https://docs.arcade-ai.com/home/install/local#install-the-engine\n",
|
" https://docs.arcade.dev/home/install/local#install-the-engine\n",
|
||||||
style="bold green",
|
style="bold green",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -229,7 +229,7 @@ def _build_engine_command(engine_config: str | None, engine_env: str | None = No
|
||||||
if not engine_bin:
|
if not engine_bin:
|
||||||
console.print(
|
console.print(
|
||||||
"❌ Engine binary not found, refer to the installation guide at "
|
"❌ Engine binary not found, refer to the installation guide at "
|
||||||
"https://docs.arcade-ai.com/guides/installation for how to install the engine",
|
"https://docs.arcade.dev/guides/installation for how to install the engine",
|
||||||
style="bold red",
|
style="bold red",
|
||||||
)
|
)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
|
||||||
|
|
@ -414,7 +414,7 @@ def evals(
|
||||||
asyncio.run(run_evaluations())
|
asyncio.run(run_evaluations())
|
||||||
|
|
||||||
|
|
||||||
@cli.command(help="Launch Arcade AI locally for tool dev", rich_help_panel="Launch")
|
@cli.command(help="Launch Arcade locally for tool dev", rich_help_panel="Launch")
|
||||||
def dev(
|
def dev(
|
||||||
host: str = typer.Option("127.0.0.1", help="Host for the worker server.", show_default=True),
|
host: str = typer.Option("127.0.0.1", help="Host for the worker server.", show_default=True),
|
||||||
port: int = typer.Option(
|
port: int = typer.Option(
|
||||||
|
|
|
||||||
|
|
@ -108,8 +108,8 @@ def serve_default_worker(
|
||||||
worker_secret = worker_secret or "dev"
|
worker_secret = worker_secret or "dev"
|
||||||
|
|
||||||
app = fastapi.FastAPI(
|
app = fastapi.FastAPI(
|
||||||
title="Arcade AI Worker",
|
title="Arcade Worker",
|
||||||
description="Arcade AI default Worker implementation using FastAPI.",
|
description="Arcade default Worker implementation using FastAPI.",
|
||||||
version="0.1.0",
|
version="0.1.0",
|
||||||
lifespan=lifespan, # Use custom lifespan to catch errors, notably KeyboardInterrupt (Ctrl+C)
|
lifespan=lifespan, # Use custom lifespan to catch errors, notably KeyboardInterrupt (Ctrl+C)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ class Config(BaseConfig):
|
||||||
If no configuration file exists, this method will create a new one with default values.
|
If no configuration file exists, this method will create a new one with default values.
|
||||||
The default configuration includes:
|
The default configuration includes:
|
||||||
- An empty API configuration
|
- An empty API configuration
|
||||||
- A default Engine configuration (host: "api.arcade-ai.com", port: None, tls: True)
|
- A default Engine configuration (host: "api.arcade.dev", port: None, tls: True)
|
||||||
- No user configuration
|
- No user configuration
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
|
||||||
|
|
@ -50,12 +50,12 @@
|
||||||
1. Run `make test` from the root of the repository
|
1. Run `make test` from the root of the repository
|
||||||
|
|
||||||
## How to run evals:
|
## How to run evals:
|
||||||
1. [Install the Arcade Engine Locally](https://docs.arcade-ai.com/home/install/local)
|
1. [Install the Arcade Engine Locally](https://docs.arcade.dev/home/install/local)
|
||||||
2. Install extra dependencies needed for evals:
|
2. Install extra dependencies needed for evals:
|
||||||
```bash
|
```bash
|
||||||
pip install 'arcade-ai[fastapi,evals]'
|
pip install 'arcade-ai[fastapi,evals]'
|
||||||
```
|
```
|
||||||
3. Log into Arcade AI:
|
3. Log into Arcade:
|
||||||
```bash
|
```bash
|
||||||
arcade login
|
arcade login
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "arcade-ai"
|
name = "arcade-ai"
|
||||||
version = "1.0.1"
|
version = "1.0.1"
|
||||||
description = "Arcade AI Python SDK and CLI"
|
description = "Arcade Python SDK and CLI"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
packages = [
|
packages = [
|
||||||
{include="arcade", from="."}
|
{include="arcade", from="."}
|
||||||
]
|
]
|
||||||
authors = ["Arcade AI <dev@arcade-ai.com>"]
|
authors = ["Arcade <dev@arcade.dev>"]
|
||||||
|
|
||||||
[build-system]
|
[build-system]
|
||||||
requires = ["poetry-core>=1.0.0"]
|
requires = ["poetry-core>=1.0.0"]
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ build-and-publish: build publish ## Build and publish.
|
||||||
|
|
||||||
.PHONY: help
|
.PHONY: help
|
||||||
help:
|
help:
|
||||||
@echo "🛠️ Arcade AI Dev Commands:\n"
|
@echo "🛠️ Arcade Dev Commands:\n"
|
||||||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
||||||
|
|
||||||
.DEFAULT_GOAL := help
|
.DEFAULT_GOAL := help
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
`langchain-arcade` allows you to use Arcade AI tools in your LangChain and LangGraph applications.
|
`langchain-arcade` allows you to use Arcade tools in your LangChain and LangGraph applications.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
name = "langchain-arcade"
|
name = "langchain-arcade"
|
||||||
version = "1.0.0"
|
version = "1.0.0"
|
||||||
description = "An integration package connecting Arcade and LangChain/LangGraph"
|
description = "An integration package connecting Arcade and LangChain/LangGraph"
|
||||||
authors = ["Arcade AI <dev@arcade-ai.com>"]
|
authors = ["Arcade <dev@arcade.dev>"]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
repository = "https://github.com/arcadeai/arcade-ai/tree/main/contrib/langchain"
|
repository = "https://github.com/arcadeai/arcade-ai/tree/main/contrib/langchain"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
|
||||||
|
|
@ -16,12 +16,12 @@ def call_non_auth_tool(client: Arcade, user_id: str) -> None:
|
||||||
This is a simple example of calling a non-auth tool. Next, try writing your own non-auth tool for your own use case.
|
This is a simple example of calling a non-auth tool. Next, try writing your own non-auth tool for your own use case.
|
||||||
"""
|
"""
|
||||||
# Prepare the inputs to the tool as a dictionary where keys are the names of the parameters expected by the tool and the values are the actual values to pass to the tool
|
# Prepare the inputs to the tool as a dictionary where keys are the names of the parameters expected by the tool and the values are the actual values to pass to the tool
|
||||||
inputs = {"a": 9001, "b": 42}
|
tool_input = {"a": 9001, "b": 42}
|
||||||
|
|
||||||
# Execute the tool
|
# Execute the tool
|
||||||
response = client.tools.execute(
|
response = client.tools.execute(
|
||||||
tool_name="Math.Add",
|
tool_name="Math.Add",
|
||||||
inputs=inputs,
|
input=tool_input,
|
||||||
user_id=user_id,
|
user_id=user_id,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -30,7 +30,7 @@ def call_non_auth_tool(client: Arcade, user_id: str) -> None:
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
cloud_host = "https://api.arcade-ai.com"
|
cloud_host = "https://api.arcade.dev"
|
||||||
|
|
||||||
client = Arcade(
|
client = Arcade(
|
||||||
base_url=cloud_host, # Alternatively, use http://localhost:9099 if you are running Arcade Engine locally, or any base_url if you're hosting elsewhere
|
base_url=cloud_host, # Alternatively, use http://localhost:9099 if you are running Arcade Engine locally, or any base_url if you're hosting elsewhere
|
||||||
|
|
|
||||||
|
|
@ -29,12 +29,12 @@ def call_auth_tool(client: Arcade, user_id: str) -> None:
|
||||||
client.auth.wait_for_completion(auth_response)
|
client.auth.wait_for_completion(auth_response)
|
||||||
|
|
||||||
# Prepare the inputs to the tool as a dictionary where keys are the names of the parameters expected by the tool and the values are the actual values to pass to the tool
|
# Prepare the inputs to the tool as a dictionary where keys are the names of the parameters expected by the tool and the values are the actual values to pass to the tool
|
||||||
inputs = {"n_emails": 5}
|
tool_input = {"n_emails": 5}
|
||||||
|
|
||||||
# Execute the tool
|
# Execute the tool
|
||||||
response = client.tools.execute(
|
response = client.tools.execute(
|
||||||
tool_name="Google.ListEmails",
|
tool_name="Google.ListEmails",
|
||||||
inputs=inputs,
|
input=tool_input,
|
||||||
user_id=user_id,
|
user_id=user_id,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -44,7 +44,7 @@ def call_auth_tool(client: Arcade, user_id: str) -> None:
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
client = Arcade(
|
client = Arcade(
|
||||||
base_url="https://api.arcade-ai.com", # Alternatively, use http://localhost:9099 if you are running Arcade Engine locally, or any base_url if you're hosting elsewhere
|
base_url="https://api.arcade.dev", # Alternatively, use http://localhost:9099 if you are running Arcade Engine locally, or any base_url if you're hosting elsewhere
|
||||||
)
|
)
|
||||||
|
|
||||||
user_id = "you@example.com"
|
user_id = "you@example.com"
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ def call_tool_with_openai(client: OpenAI) -> dict:
|
||||||
messages=[
|
messages=[
|
||||||
{"role": "user", "content": "Star the ArcadeAI/arcade-ai repository."},
|
{"role": "user", "content": "Star the ArcadeAI/arcade-ai repository."},
|
||||||
],
|
],
|
||||||
model="gpt-4o-mini", # TODO: Try "claude-3-5-sonnet-20240620" or other models from our supported model providers. Checkout out our docs for a full list: https://docs.arcade-ai.com/integrations
|
model="gpt-4o-mini", # TODO: Try "claude-3-5-sonnet-20240620" or other models from our supported model providers. Checkout out our docs for a full list https://docs.arcade.dev
|
||||||
user="you@example.com",
|
user="you@example.com",
|
||||||
tools=["Github.SetStarred"],
|
tools=["Github.SetStarred"],
|
||||||
tool_choice="generate", # TODO: Try "execute" and note any differences
|
tool_choice="generate", # TODO: Try "execute" and note any differences
|
||||||
|
|
@ -25,7 +25,7 @@ if __name__ == "__main__":
|
||||||
arcade_api_key = os.environ.get(
|
arcade_api_key = os.environ.get(
|
||||||
"ARCADE_API_KEY"
|
"ARCADE_API_KEY"
|
||||||
) # If you forget your Arcade API key, it is stored at ~/.arcade/credentials.yaml on `arcade login`
|
) # If you forget your Arcade API key, it is stored at ~/.arcade/credentials.yaml on `arcade login`
|
||||||
cloud_host = "https://api.arcade-ai.com" + "/v1"
|
cloud_host = "https://api.arcade.dev" + "/v1"
|
||||||
|
|
||||||
openai_client = OpenAI(
|
openai_client = OpenAI(
|
||||||
api_key=arcade_api_key,
|
api_key=arcade_api_key,
|
||||||
|
|
|
||||||
|
|
@ -1,119 +0,0 @@
|
||||||
"""Example script demonstrating how to call multiple tools directly with authentication.
|
|
||||||
|
|
||||||
For this example, we are using the prebuilt Spotify toolkit to start playing similar songs to the currently playing song.
|
|
||||||
|
|
||||||
Steps:
|
|
||||||
1. Search for the song
|
|
||||||
2. Start playing the song
|
|
||||||
3. Get info about the currently playing song
|
|
||||||
4. Inform the user which song is now playing
|
|
||||||
"""
|
|
||||||
|
|
||||||
from typing import Any, Optional
|
|
||||||
|
|
||||||
from arcade_spotify.tools.models import SearchType
|
|
||||||
from arcadepy import Arcade # pip install arcade-py
|
|
||||||
|
|
||||||
|
|
||||||
# Need to click on a link for every provider
|
|
||||||
def get_permissions(client: Arcade, provider_to_scopes: dict, user_id: str) -> None:
|
|
||||||
"""Prompt the user to authorize necessary permissions for each provider."""
|
|
||||||
for provider, scopes in provider_to_scopes.items():
|
|
||||||
auth_response = client.auth.start(
|
|
||||||
user_id=user_id,
|
|
||||||
provider=provider,
|
|
||||||
scopes=scopes,
|
|
||||||
)
|
|
||||||
|
|
||||||
if auth_response.status != "completed":
|
|
||||||
print(f"Click this link to authorize: {auth_response.authorization_url}")
|
|
||||||
input("After you have authorized, press Enter to continue...")
|
|
||||||
|
|
||||||
|
|
||||||
def call_tool(client: Arcade, tool_name: str, user_id: str, inputs: Optional[dict] = None) -> Any:
|
|
||||||
"""Call a single tool."""
|
|
||||||
if inputs is None:
|
|
||||||
inputs = {}
|
|
||||||
|
|
||||||
response = client.tools.execute(
|
|
||||||
tool_name=tool_name,
|
|
||||||
inputs=inputs,
|
|
||||||
user_id=user_id,
|
|
||||||
)
|
|
||||||
|
|
||||||
if response.output.error:
|
|
||||||
print(response.output.error)
|
|
||||||
|
|
||||||
return response.output.value
|
|
||||||
|
|
||||||
|
|
||||||
def search_and_play_song(
|
|
||||||
client: Arcade,
|
|
||||||
provider_to_scopes: dict,
|
|
||||||
tools: list[str],
|
|
||||||
user_id: str,
|
|
||||||
song_name: str,
|
|
||||||
artist_name: str,
|
|
||||||
) -> None:
|
|
||||||
"""Execute the sequence of tools to get recommendations and start playback."""
|
|
||||||
get_permissions(client, provider_to_scopes, user_id)
|
|
||||||
|
|
||||||
(
|
|
||||||
search_tool,
|
|
||||||
start_playback_tool,
|
|
||||||
get_currently_playing_tool,
|
|
||||||
) = tools
|
|
||||||
|
|
||||||
# Step 1: search for the song
|
|
||||||
response = call_tool(
|
|
||||||
client=client,
|
|
||||||
tool_name=search_tool,
|
|
||||||
user_id=user_id,
|
|
||||||
inputs={
|
|
||||||
"q": f"{song_name} {artist_name}",
|
|
||||||
"types": [SearchType.TRACK],
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
if not response["tracks"]["items"]:
|
|
||||||
print("Sorry, I couldn't find that song on Spotify.")
|
|
||||||
return
|
|
||||||
|
|
||||||
# Step 2: Start playing the song
|
|
||||||
track_id = response["tracks"]["items"][0]["id"]
|
|
||||||
response = call_tool(
|
|
||||||
client,
|
|
||||||
start_playback_tool,
|
|
||||||
user_id,
|
|
||||||
inputs={"track_ids": [track_id]},
|
|
||||||
)
|
|
||||||
|
|
||||||
# Step 3: get currently playing song
|
|
||||||
response = call_tool(client, get_currently_playing_tool, user_id)
|
|
||||||
print(
|
|
||||||
f"\nNow playing: {response['track_name']} by {', '.join(response['track_artists'])} - {response['track_spotify_url']}"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
client = Arcade(base_url="https://api.arcade-ai.com")
|
|
||||||
|
|
||||||
# Necessary scopes for the tools we are calling:
|
|
||||||
provider_to_scopes = {
|
|
||||||
"spotify": [
|
|
||||||
"user-read-currently-playing",
|
|
||||||
"user-read-playback-state",
|
|
||||||
],
|
|
||||||
}
|
|
||||||
|
|
||||||
tools = [
|
|
||||||
"Spotify.Search", # Search for a song
|
|
||||||
"Spotify.StartTracksPlaybackById", # Start playing the song
|
|
||||||
"Spotify.GetCurrentlyPlaying", # Get info about the current song
|
|
||||||
]
|
|
||||||
|
|
||||||
user_id = "you@example.com"
|
|
||||||
song_name = input("Enter the song name: ")
|
|
||||||
artist_name = input("Enter the artist name: ")
|
|
||||||
|
|
||||||
search_and_play_song(client, provider_to_scopes, tools, user_id, song_name, artist_name)
|
|
||||||
|
|
@ -1,80 +0,0 @@
|
||||||
"""
|
|
||||||
Example script demonstrating how to call multiple tools (sequentially) using an LLM with authentication.
|
|
||||||
|
|
||||||
For this example, we are using the prebuilt Spotify toolkit to search for a song, start playing it, and
|
|
||||||
get info about the currently playing song.
|
|
||||||
|
|
||||||
Steps:
|
|
||||||
1. Search for the song
|
|
||||||
2. Start playing the song
|
|
||||||
3. Get info about the currently playing song
|
|
||||||
4. Inform the user which song is now playing
|
|
||||||
"""
|
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
from openai import OpenAI
|
|
||||||
|
|
||||||
|
|
||||||
def call_tool(client: OpenAI, user_id: str, tool: str, message: dict, history: list[dict]) -> str:
|
|
||||||
"""Make a tool call with a specific tool and message."""
|
|
||||||
response = client.chat.completions.create(
|
|
||||||
messages=[
|
|
||||||
*history,
|
|
||||||
message,
|
|
||||||
],
|
|
||||||
model="gpt-4o",
|
|
||||||
user=user_id,
|
|
||||||
tools=[tool],
|
|
||||||
tool_choice="generate",
|
|
||||||
)
|
|
||||||
return response
|
|
||||||
|
|
||||||
|
|
||||||
def call_tools_with_llm(
|
|
||||||
client: OpenAI, user_id: str, song_name: str, artist_name: str
|
|
||||||
) -> list[dict]:
|
|
||||||
"""Use an LLM to execute the sequence of tools to search for a song and start playback."""
|
|
||||||
tools = [
|
|
||||||
"Spotify.Search",
|
|
||||||
"Spotify.StartTracksPlaybackById",
|
|
||||||
"Spotify.GetCurrentlyPlaying",
|
|
||||||
]
|
|
||||||
|
|
||||||
messages = [
|
|
||||||
{"role": "user", "content": f"Search for '{song_name}' by {artist_name}' on Spotify."},
|
|
||||||
{"role": "user", "content": "Start playing the song. Just one tool call."},
|
|
||||||
{"role": "user", "content": "Get the currently playing song."},
|
|
||||||
]
|
|
||||||
|
|
||||||
history = []
|
|
||||||
for i in range(len(messages)):
|
|
||||||
response = call_tool(client, user_id, tools[i], messages[i], history)
|
|
||||||
print("\n\n", response.choices[0].message.content)
|
|
||||||
if (
|
|
||||||
response.choices[0].tool_authorizations
|
|
||||||
and response.choices[0].tool_authorizations[0].get("status") == "pending"
|
|
||||||
):
|
|
||||||
input("\nPress Enter once you have authorized...")
|
|
||||||
response = call_tool(client, user_id, tools[i], messages[i], history)
|
|
||||||
history.append(messages[i])
|
|
||||||
history.append({"role": "assistant", "content": response.choices[0].message.content})
|
|
||||||
|
|
||||||
return history
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
arcade_api_key = os.environ.get("ARCADE_API_KEY")
|
|
||||||
cloud_host = "https://api.arcade-ai.com/v1"
|
|
||||||
|
|
||||||
openai_client = OpenAI(
|
|
||||||
api_key=arcade_api_key,
|
|
||||||
base_url=cloud_host,
|
|
||||||
)
|
|
||||||
|
|
||||||
user_id = "you@example.com"
|
|
||||||
song_name = input("Enter the song name: ")
|
|
||||||
artist_name = input("Enter the artist name: ")
|
|
||||||
|
|
||||||
history = call_tools_with_llm(openai_client, user_id, song_name, artist_name)
|
|
||||||
print("\n\n", history)
|
|
||||||
|
|
@ -22,7 +22,7 @@ def get_auth_token(client: Arcade, user_id: str) -> str:
|
||||||
)
|
)
|
||||||
|
|
||||||
if auth_response.status != "completed":
|
if auth_response.status != "completed":
|
||||||
print(f"Click this link to authorize: {auth_response.authorization_url}")
|
print(f"Click this link to authorize: {auth_response.url}")
|
||||||
auth_response = client.auth.wait_for_completion(auth_response)
|
auth_response = client.auth.wait_for_completion(auth_response)
|
||||||
|
|
||||||
return auth_response.context.token
|
return auth_response.context.token
|
||||||
|
|
@ -46,7 +46,7 @@ def use_auth_token(token: str) -> None:
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
cloud_host = "https://api.arcade-ai.com"
|
cloud_host = "https://api.arcade.dev"
|
||||||
|
|
||||||
client = Arcade(
|
client = Arcade(
|
||||||
base_url=cloud_host, # Alternatively, use http://localhost:9099 if you are running Arcade locally, or any base_url if you're hosting elsewhere
|
base_url=cloud_host, # Alternatively, use http://localhost:9099 if you are running Arcade locally, or any base_url if you're hosting elsewhere
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
### API keys
|
### API keys
|
||||||
|
|
||||||
Follow [these instructions](https://docs.arcade.dev/home/custom-tools/) to Install Arcade AI and create an API key.
|
Follow [these instructions](https://docs.arcade.dev/home/custom-tools/) to Install Arcade and create an API key.
|
||||||
|
|
||||||
This example is using OpenAI, as the LLM provider. Ensure you have an [OpenAI API key](https://platform.openai.com/docs/quickstart).
|
This example is using OpenAI, as the LLM provider. Ensure you have an [OpenAI API key](https://platform.openai.com/docs/quickstart).
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
"""
|
"""
|
||||||
Example script demonstrating how to build a simple chatbot with Arcade AI.
|
Example script demonstrating how to build a simple chatbot with Arcade.
|
||||||
|
|
||||||
For this example, we are using the prebuilt Google Docs toolkit to create and edit documents.
|
For this example, we are using the prebuilt Google Docs toolkit to create and edit documents.
|
||||||
|
|
||||||
|
|
@ -55,20 +55,22 @@ if __name__ == "__main__":
|
||||||
arcade_api_key = os.environ.get(
|
arcade_api_key = os.environ.get(
|
||||||
"ARCADE_API_KEY"
|
"ARCADE_API_KEY"
|
||||||
) # If you forget your Arcade API key, it is stored at ~/.arcade/credentials.yaml on `arcade login`
|
) # If you forget your Arcade API key, it is stored at ~/.arcade/credentials.yaml on `arcade login`
|
||||||
local_host = "http://localhost:9099/v1"
|
cloud_host = "https://api.arcade.dev/v1"
|
||||||
user_id = "user@example.com"
|
user_id = "user@example.com"
|
||||||
|
|
||||||
openai_client = OpenAI(
|
openai_client = OpenAI(
|
||||||
api_key=arcade_api_key,
|
api_key=arcade_api_key,
|
||||||
base_url=local_host,
|
base_url=cloud_host,
|
||||||
)
|
)
|
||||||
|
|
||||||
tool_names = [
|
tool_names = [
|
||||||
"Google.GetDocumentById",
|
"Google.SendEmail",
|
||||||
"Google.InsertTextAtEndOfDocument",
|
"Google.SendDraftEmail",
|
||||||
"Google.CreateBlankDocument",
|
"Google.WriteDraftEmail",
|
||||||
"Google.CreateDocumentFromText",
|
"Google.UpdateDraftEmail",
|
||||||
"Google.ListDocuments",
|
"Google.ListDraftEmails",
|
||||||
|
"Google.ListEmailsByHeader",
|
||||||
|
"Google.ListEmails",
|
||||||
]
|
]
|
||||||
|
|
||||||
chat(openai_client, tool_names, user_id)
|
chat(openai_client, tool_names, user_id)
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
name = "arcade_code_sandbox"
|
name = "arcade_code_sandbox"
|
||||||
version = "0.1.9"
|
version = "0.1.9"
|
||||||
description = "LLM tools for running code in a sandbox"
|
description = "LLM tools for running code in a sandbox"
|
||||||
authors = ["Arcade AI <dev@arcade-ai.com>"]
|
authors = ["Arcade <dev@arcade.dev>"]
|
||||||
|
|
||||||
[tool.poetry.dependencies]
|
[tool.poetry.dependencies]
|
||||||
python = "^3.10"
|
python = "^3.10"
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
name = "arcade_github"
|
name = "arcade_github"
|
||||||
version = "0.1.9"
|
version = "0.1.9"
|
||||||
description = "LLM tools for interacting with Github"
|
description = "LLM tools for interacting with Github"
|
||||||
authors = ["Arcade AI <dev@arcade-ai.com>"]
|
authors = ["Arcade <dev@arcade.dev>"]
|
||||||
|
|
||||||
[tool.poetry.dependencies]
|
[tool.poetry.dependencies]
|
||||||
python = "^3.10"
|
python = "^3.10"
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
name = "arcade_google"
|
name = "arcade_google"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
description = "Arcade tools for the entire google suite"
|
description = "Arcade tools for the entire google suite"
|
||||||
authors = ["Arcade AI <dev@arcade-ai.com>"]
|
authors = ["Arcade <dev@arcade.dev>"]
|
||||||
|
|
||||||
[tool.poetry.dependencies]
|
[tool.poetry.dependencies]
|
||||||
python = "^3.10"
|
python = "^3.10"
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
name = "arcade_linkedin"
|
name = "arcade_linkedin"
|
||||||
version = "0.1.10"
|
version = "0.1.10"
|
||||||
description = "Arcade tools for LinkedIn"
|
description = "Arcade tools for LinkedIn"
|
||||||
authors = ["Arcade AI <dev@arcade-ai.com>"]
|
authors = ["Arcade <dev@arcade.dev>"]
|
||||||
|
|
||||||
[tool.poetry.dependencies]
|
[tool.poetry.dependencies]
|
||||||
python = "^3.10"
|
python = "^3.10"
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
name = "arcade_math"
|
name = "arcade_math"
|
||||||
version = "0.1.9"
|
version = "0.1.9"
|
||||||
description = "Math toolkit for Arcade"
|
description = "Math toolkit for Arcade"
|
||||||
authors = ["Arcade AI <dev@arcade-ai.com>"]
|
authors = ["Arcade <dev@arcade.dev>"]
|
||||||
|
|
||||||
[tool.poetry.dependencies]
|
[tool.poetry.dependencies]
|
||||||
python = "^3.10"
|
python = "^3.10"
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
name = "arcade_search"
|
name = "arcade_search"
|
||||||
version = "0.1.10"
|
version = "0.1.10"
|
||||||
description = "Tools for searching the web"
|
description = "Tools for searching the web"
|
||||||
authors = ["Arcade AI <dev@arcade-ai.com>"]
|
authors = ["Arcade <dev@arcade.dev>"]
|
||||||
|
|
||||||
[tool.poetry.dependencies]
|
[tool.poetry.dependencies]
|
||||||
python = "^3.10"
|
python = "^3.10"
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
name = "arcade_slack"
|
name = "arcade_slack"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
description = "Slack tools for LLMs"
|
description = "Slack tools for LLMs"
|
||||||
authors = ["Arcade AI <dev@arcade-ai.com>"]
|
authors = ["Arcade <dev@arcade.dev>"]
|
||||||
|
|
||||||
[tool.poetry.dependencies]
|
[tool.poetry.dependencies]
|
||||||
python = "^3.10"
|
python = "^3.10"
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
name = "arcade_spotify"
|
name = "arcade_spotify"
|
||||||
version = "0.2.1"
|
version = "0.2.1"
|
||||||
description = "Arcade tools for Spotify"
|
description = "Arcade tools for Spotify"
|
||||||
authors = ["Arcade AI <dev@arcade-ai.com>"]
|
authors = ["Arcade <dev@arcade.dev>"]
|
||||||
|
|
||||||
[tool.poetry.dependencies]
|
[tool.poetry.dependencies]
|
||||||
python = "^3.10"
|
python = "^3.10"
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
name = "arcade_web"
|
name = "arcade_web"
|
||||||
version = "0.1.9"
|
version = "0.1.9"
|
||||||
description = "LLM tools for web-related tasks"
|
description = "LLM tools for web-related tasks"
|
||||||
authors = ["Arcade AI <dev@arcade-ai.com>"]
|
authors = ["Arcade <dev@arcade.dev>"]
|
||||||
|
|
||||||
[tool.poetry.dependencies]
|
[tool.poetry.dependencies]
|
||||||
python = "^3.10"
|
python = "^3.10"
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
name = "arcade_x"
|
name = "arcade_x"
|
||||||
version = "0.1.11"
|
version = "0.1.11"
|
||||||
description = "LLM tools for interacting with X (Twitter)"
|
description = "LLM tools for interacting with X (Twitter)"
|
||||||
authors = ["Arcade AI <dev@arcade-ai.com>"]
|
authors = ["Arcade <dev@arcade.dev>"]
|
||||||
|
|
||||||
[tool.poetry.dependencies]
|
[tool.poetry.dependencies]
|
||||||
python = "^3.10"
|
python = "^3.10"
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
name = "arcade_zoom"
|
name = "arcade_zoom"
|
||||||
version = "0.1.10"
|
version = "0.1.10"
|
||||||
description = "Arcade tools for Zoom"
|
description = "Arcade tools for Zoom"
|
||||||
authors = ["Arcade AI <dev@arcade-ai.com>"]
|
authors = ["Arcade <dev@arcade.dev>"]
|
||||||
|
|
||||||
[tool.poetry.dependencies]
|
[tool.poetry.dependencies]
|
||||||
python = "^3.10"
|
python = "^3.10"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue