Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 142 additions & 0 deletions pages/toolkits/search/google_maps.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
# Search

import ToolInfo from "@/components/ToolInfo";
import Badges from "@/components/Badges";
import TabbedCodeBlock from "@/components/TabbedCodeBlock";
import TableOfContents from "@/components/TableOfContents";

<ToolInfo
description="Enable agents to get directions between two locations with Google Maps."
author="Arcade"
codeLink="https://github.com/ArcadeAI/arcade-ai/tree/main/toolkits/search"
authType="API Key"
versions={["0.1.0"]}
/>

<Badges repo="arcadeai/arcade_search" />

The Arcade Google Maps toolkit provides a pre-built set of tools for interacting with Google Maps. These tools make it easy to build agents and AI apps that can:

- Get directions to a location using an address or latitude/longitude.

## Install

```bash
pip install arcade_search
```

<Note>
pip installing the toolkit is only needed if you are [self-hosting](/home/install/overview) Arcade. You do not need to install the toolkit if you're using Arcade Cloud.
</Note>

## Available Tools

<TableOfContents
headers={["Tool Name", "Description"]}
data={
[
["GetDirectionsBetweenAddresses", "Get directions between two addresses."],
["GetDirectionsBetweenCoordinates", "Get directions between two latitude/longitude coordinates."],
]
}
/>

<Tip>
If you need to perform an action that's not listed here, you can [get in touch
with us](mailto:[email protected]) to request a new tool, or [create your
own tools](/home/build-tools/create-a-toolkit).
</Tip>

## GetDirectionsBetweenAddresses

<br />
<TabbedCodeBlock
tabs={[
{
label: "Call the Tool Directly",
content: {
Python: [
"/examples/integrations/toolkits/search/get_directions_between_addresses_example_call_tool.py",
],
JavaScript: ["/examples/integrations/toolkits/search/get_directions_between_addresses_example_call_tool.js"],
},
},
{
label: "Execute the Tool with OpenAI",
content: {
Python: [
"/examples/integrations/toolkits/search/get_directions_between_addresses_example_llm_oai.py",
],
JavaScript: ["/examples/integrations/toolkits/search/get_directions_between_addresses_example_llm_oai.js"],
},
},
]}
/>

Get directions between two addresses.

**Auth:**

- **Environment Variables Required:**
- `SERP_API_KEY`: Your SerpAPI API key.

**Parameters**

- **`origin_address`** _(string, required)_ The origin address. Example: '123 Main St, New York, NY 10001'.
- **`destination_address`** _(string, required)_ The destination address. Example: '456 Main St, New York, NY 10001'.
- **`language`** _(string, optional, Defaults to 'en' English)_ 2-character language code to use in the Google Maps search.
- **`country`** _(string, optional, Defaults to `None`)_ 2-character country code to use in the Google Maps search.
- **`distance_unit`** _(enum ([GoogleMapsDistanceUnit](/toolkits/search/reference#googlemapsdistanceunit)), optional, Defaults to `GoogleMapsDistanceUnit.KM`)_ Distance unit to use in the Google Maps search.
- **`travel_mode`** _(enum ([GoogleMapsTravelMode](/toolkits/search/reference#googlemapstravelmode)), optional, Defaults to `GoogleMapsTravelMode.BEST`)_ Travel mode to use in the Google Maps search.

## GetDirectionsBetweenCoordinates

<br />
<TabbedCodeBlock
tabs={[
{
label: "Call the Tool Directly",
content: {
Python: [
"/examples/integrations/toolkits/search/get_directions_between_coordinates_example_call_tool.py",
],
JavaScript: ["/examples/integrations/toolkits/search/get_directions_between_coordinates_example_call_tool.js"],
},
},
{
label: "Execute the Tool with OpenAI",
content: {
Python: [
"/examples/integrations/toolkits/search/get_directions_between_coordinates_example_llm_oai.py",
],
JavaScript: ["/examples/integrations/toolkits/search/get_directions_between_coordinates_example_llm_oai.js"],
},
},
]}
/>

Get directions between two latitude/longitude coordinates.

**Auth:**

- **Environment Variables Required:**
- `SERP_API_KEY`: Your SerpAPI API key.

**Parameters**

- **`origin_latitude`** _(float, required)_ The origin latitude.
- **`origin_longitude`** _(float, required)_ The origin longitude.
- **`destination_latitude`** _(float, required)_ The destination latitude.
- **`destination_longitude`** _(float, required)_ The destination longitude.
- **`language`** _(string, optional, Defaults to 'en' English)_ 2-character language code to use in the Google Maps search.
- **`country`** _(string, optional, Defaults to `None`)_ 2-character country code to use in the Google Maps search.
- **`distance_unit`** _(enum ([GoogleMapsDistanceUnit](/toolkits/search/reference#googlemapsdistanceunit)), optional, Defaults to `GoogleMapsDistanceUnit.KM`)_ Distance unit to use in the Google Maps search.
- **`travel_mode`** _(enum ([GoogleMapsTravelMode](/toolkits/search/reference#googlemapstravelmode)), optional, Defaults to `GoogleMapsTravelMode.BEST`)_ Travel mode to use in the Google Maps search.

## Auth

The Arcade Google Maps toolkit uses the [SerpAPI](https://serpapi.com/) to get directions and search Google Maps.

**Global Environment Variables:**

- `SERP_API_KEY`: Your SerpAPI API key.
20 changes: 20 additions & 0 deletions pages/toolkits/search/reference.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Reference for Search Toolkit

## GoogleMapsDistanceUnit

Distance unit to use in the Google Maps search.

- **`KM`**: Kilometers.
- **`MI`**: Miles.

## GoogleMapsTravelMode

Travel mode to use in the Google Maps search.

- **`BEST`**: Best mode.
- **`DRIVING`**: Driving mode.
- **`MOTORCYCLE`**: Motorcycle mode.
- **`PUBLIC_TRANSPORTATION`**: Public transportation mode.
- **`WALKING`**: Walking mode.
- **`BICYCLE`**: Bicycling mode.
- **`FLIGHT`**: Flight mode.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Arcade } from "@arcadeai/arcadejs";

const client = new Arcade(); // Automatically finds the `ARCADE_API_KEY` env variable

const USER_ID = "[email protected]";
const TOOL_NAME = "Search.GetDirectionsBetweenAddresses";

const toolInput = {
origin_address: "123 Main St, New York, NY 10001",
destination_address: "456 Main St, New York, NY 10001",
distance_unit: "KM",
travel_mode: "BEST",
};

const response = await client.tools.execute({
tool_name: TOOL_NAME,
input: toolInput,
user_id: USER_ID,
});

console.log(response);
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from arcadepy import Arcade

client = Arcade() # Automatically finds the `ARCADE_API_KEY` env variable

USER_ID = "[email protected]"
TOOL_NAME = "Search.GetDirectionsBetweenAddresses"

tool_input = {
"origin_address": "123 Main St, New York, NY 10001",
"destination_address": "456 Main St, New York, NY 10001",
"distance_unit": "KM",
"travel_mode": "BEST",
}

response = client.tools.execute(
tool_name=TOOL_NAME,
input=tool_input,
user_id=USER_ID,
)
print(response)
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import OpenAI from "openai";

const USER_ID = "[email protected]";
const PROMPT =
"Get directions between '123 Main St, New York, NY 10001' and '456 Main St, New York, NY 10001'.";
const TOOL_NAME = "Search.GetDirectionsBetweenAddresses";

const client = new OpenAI({
baseURL: "https://api.arcade.dev",
apiKey: process.env.ARCADE_API_KEY,
});

const response = await client.chat.completions.create({
messages: [{ role: "user", content: PROMPT }],
model: "gpt-4o-mini",
user: USER_ID,
tools: [TOOL_NAME],
tool_choice: "generate",
});

console.log(response.choices[0].message.content);
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import os
from openai import OpenAI

USER_ID = "[email protected]"
PROMPT = "Get directions between '123 Main St, New York, NY 10001' and '456 Main St, New York, NY 10001'."
TOOL_NAME = "Search.GetDirectionsBetweenAddresses"

client = OpenAI(
base_url="https://api.arcade.dev", api_key=os.environ.get("ARCADE_API_KEY")
)

response = client.chat.completions.create(
messages=[
{"role": "user", "content": PROMPT},
],
model="gpt-4o-mini",
user=USER_ID,
tools=[TOOL_NAME],
tool_choice="generate",
)
print(response.choices[0].message.content)
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Arcade } from "@arcadeai/arcadejs";

const client = new Arcade(); // Automatically finds the `ARCADE_API_KEY` env variable

const USER_ID = "[email protected]";
const TOOL_NAME = "Search.GetDirectionsBetweenCoordinates";

const toolInput = {
origin_latitude: 37.7879,
origin_longitude: -122.4076,
destination_latitude: 37.8219,
destination_longitude: -122.4789,
distance_unit: "KM",
travel_mode: "BEST",
};

const response = await client.tools.execute({
tool_name: TOOL_NAME,
input: toolInput,
user_id: USER_ID,
});

console.log(response);
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from arcadepy import Arcade

client = Arcade() # Automatically finds the `ARCADE_API_KEY` env variable

USER_ID = "[email protected]"
TOOL_NAME = "Search.GetDirectionsBetweenCoordinates"

tool_input = {
"origin_latitude": 37.7879,
"origin_longitude": -122.4076,
"destination_latitude": 37.8219,
"destination_longitude": -122.4789,
"distance_unit": "KM",
"travel_mode": "BEST",
}

response = client.tools.execute(
tool_name=TOOL_NAME,
input=tool_input,
user_id=USER_ID,
)
print(response)
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import OpenAI from "openai";

const USER_ID = "[email protected]";
const PROMPT =
"Get directions between the following coordinates: 37.7879, -122.4076 and 37.8219, -122.4789.";
const TOOL_NAME = "Search.GetDirectionsBetweenCoordinates";

const client = new OpenAI({
baseURL: "https://api.arcade.dev",
apiKey: process.env.ARCADE_API_KEY,
});

const response = await client.chat.completions.create({
messages: [{ role: "user", content: PROMPT }],
model: "gpt-4o-mini",
user: USER_ID,
tools: [TOOL_NAME],
tool_choice: "generate",
});

console.log(response.choices[0].message.content);
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import os
from openai import OpenAI

USER_ID = "[email protected]"
PROMPT = "Get directions between the following coordinates: 37.7879, -122.4076 and 37.8219, -122.4789."
TOOL_NAME = "Search.GetDirectionsBetweenCoordinates"

client = OpenAI(
base_url="https://api.arcade.dev", api_key=os.environ.get("ARCADE_API_KEY")
)

response = client.chat.completions.create(
messages=[
{"role": "user", "content": PROMPT},
],
model="gpt-4o-mini",
user=USER_ID,
tools=[TOOL_NAME],
tool_choice="generate",
)
print(response.choices[0].message.content)
Binary file added public/images/icons/google_maps.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 14 additions & 5 deletions src/components/custom/Toolkits/toolkits-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const categories: Category[] = [
{ id: "social", name: "Social & Communication" },
{ id: "development", name: "Developer Tools" },
{ id: "entertainment", name: "Entertainment" },
{ id: "search", name: "Search" },
];

export const tools: Tool[] = [
Expand Down Expand Up @@ -118,11 +119,19 @@ export const tools: Tool[] = [
type: "arcade",
},
{
name: "Search",
image: "serpapi",
summary: "Perform web searches and retrieve relevant information",
link: "/toolkits/development/search",
category: "development",
name: "Google Search",
image: "google_search",
summary: "Perform Google searches and retrieve relevant information",
link: "/toolkits/search/google_search",
category: "search",
type: "arcade",
},
{
name: "Google Maps",
image: "google_maps",
summary: "Get directions between two locations with Google Maps",
link: "/toolkits/search/google_maps",
category: "search",
type: "arcade",
},
{
Expand Down