diff --git a/pages/toolkits/search/google_maps.mdx b/pages/toolkits/search/google_maps.mdx new file mode 100644 index 000000000..b2afef79d --- /dev/null +++ b/pages/toolkits/search/google_maps.mdx @@ -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"; + + + + + +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 +``` + + + 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. + + +## Available Tools + + + + + If you need to perform an action that's not listed here, you can [get in touch + with us](mailto:contact@arcade.dev) to request a new tool, or [create your + own tools](/home/build-tools/create-a-toolkit). + + +## GetDirectionsBetweenAddresses + +
+ + +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 + +
+ + +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. diff --git a/pages/toolkits/development/search.mdx b/pages/toolkits/search/google_search.mdx similarity index 100% rename from pages/toolkits/development/search.mdx rename to pages/toolkits/search/google_search.mdx diff --git a/pages/toolkits/search/reference.mdx b/pages/toolkits/search/reference.mdx new file mode 100644 index 000000000..6ffac4851 --- /dev/null +++ b/pages/toolkits/search/reference.mdx @@ -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. diff --git a/public/examples/integrations/toolkits/search/get_directions_between_addresses_example_call_tool.js b/public/examples/integrations/toolkits/search/get_directions_between_addresses_example_call_tool.js new file mode 100644 index 000000000..c08f7dd0f --- /dev/null +++ b/public/examples/integrations/toolkits/search/get_directions_between_addresses_example_call_tool.js @@ -0,0 +1,21 @@ +import { Arcade } from "@arcadeai/arcadejs"; + +const client = new Arcade(); // Automatically finds the `ARCADE_API_KEY` env variable + +const USER_ID = "you@example.com"; +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); diff --git a/public/examples/integrations/toolkits/search/get_directions_between_addresses_example_call_tool.py b/public/examples/integrations/toolkits/search/get_directions_between_addresses_example_call_tool.py new file mode 100644 index 000000000..a59d1a3ed --- /dev/null +++ b/public/examples/integrations/toolkits/search/get_directions_between_addresses_example_call_tool.py @@ -0,0 +1,20 @@ +from arcadepy import Arcade + +client = Arcade() # Automatically finds the `ARCADE_API_KEY` env variable + +USER_ID = "you@example.com" +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) diff --git a/public/examples/integrations/toolkits/search/get_directions_between_addresses_example_llm_oai.js b/public/examples/integrations/toolkits/search/get_directions_between_addresses_example_llm_oai.js new file mode 100644 index 000000000..a5a21414c --- /dev/null +++ b/public/examples/integrations/toolkits/search/get_directions_between_addresses_example_llm_oai.js @@ -0,0 +1,21 @@ +import OpenAI from "openai"; + +const USER_ID = "you@example.com"; +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); diff --git a/public/examples/integrations/toolkits/search/get_directions_between_addresses_example_llm_oai.py b/public/examples/integrations/toolkits/search/get_directions_between_addresses_example_llm_oai.py new file mode 100644 index 000000000..f744cf894 --- /dev/null +++ b/public/examples/integrations/toolkits/search/get_directions_between_addresses_example_llm_oai.py @@ -0,0 +1,21 @@ +import os +from openai import OpenAI + +USER_ID = "you@example.com" +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) diff --git a/public/examples/integrations/toolkits/search/get_directions_between_coordinates_example_call_tool.js b/public/examples/integrations/toolkits/search/get_directions_between_coordinates_example_call_tool.js new file mode 100644 index 000000000..55e9e9e8f --- /dev/null +++ b/public/examples/integrations/toolkits/search/get_directions_between_coordinates_example_call_tool.js @@ -0,0 +1,23 @@ +import { Arcade } from "@arcadeai/arcadejs"; + +const client = new Arcade(); // Automatically finds the `ARCADE_API_KEY` env variable + +const USER_ID = "you@example.com"; +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); diff --git a/public/examples/integrations/toolkits/search/get_directions_between_coordinates_example_call_tool.py b/public/examples/integrations/toolkits/search/get_directions_between_coordinates_example_call_tool.py new file mode 100644 index 000000000..1a8627de6 --- /dev/null +++ b/public/examples/integrations/toolkits/search/get_directions_between_coordinates_example_call_tool.py @@ -0,0 +1,22 @@ +from arcadepy import Arcade + +client = Arcade() # Automatically finds the `ARCADE_API_KEY` env variable + +USER_ID = "you@example.com" +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) diff --git a/public/examples/integrations/toolkits/search/get_directions_between_coordinates_example_llm_oai.js b/public/examples/integrations/toolkits/search/get_directions_between_coordinates_example_llm_oai.js new file mode 100644 index 000000000..fe97a0528 --- /dev/null +++ b/public/examples/integrations/toolkits/search/get_directions_between_coordinates_example_llm_oai.js @@ -0,0 +1,21 @@ +import OpenAI from "openai"; + +const USER_ID = "you@example.com"; +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); diff --git a/public/examples/integrations/toolkits/search/get_directions_between_coordinates_example_llm_oai.py b/public/examples/integrations/toolkits/search/get_directions_between_coordinates_example_llm_oai.py new file mode 100644 index 000000000..288669c15 --- /dev/null +++ b/public/examples/integrations/toolkits/search/get_directions_between_coordinates_example_llm_oai.py @@ -0,0 +1,21 @@ +import os +from openai import OpenAI + +USER_ID = "you@example.com" +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) diff --git a/public/images/icons/google_maps.png b/public/images/icons/google_maps.png new file mode 100644 index 000000000..01fb5c76e Binary files /dev/null and b/public/images/icons/google_maps.png differ diff --git a/src/components/custom/Toolkits/toolkits-config.ts b/src/components/custom/Toolkits/toolkits-config.ts index 87d4fe292..f8a962661 100644 --- a/src/components/custom/Toolkits/toolkits-config.ts +++ b/src/components/custom/Toolkits/toolkits-config.ts @@ -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[] = [ @@ -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", }, {