From f49078c11adbaf9aed57876898bd4c69b8379385 Mon Sep 17 00:00:00 2001 From: Renato Byrro Date: Mon, 17 Mar 2025 22:34:00 -0300 Subject: [PATCH] document google maps tools --- pages/toolkits/search/google_maps.mdx | 142 ++++++++++++++++++ .../search.mdx => search/google_search.mdx} | 0 pages/toolkits/search/reference.mdx | 20 +++ ...ons_between_addresses_example_call_tool.js | 21 +++ ...ons_between_addresses_example_call_tool.py | 20 +++ ...tions_between_addresses_example_llm_oai.js | 21 +++ ...tions_between_addresses_example_llm_oai.py | 21 +++ ...s_between_coordinates_example_call_tool.js | 23 +++ ...s_between_coordinates_example_call_tool.py | 22 +++ ...ons_between_coordinates_example_llm_oai.js | 21 +++ ...ons_between_coordinates_example_llm_oai.py | 21 +++ public/images/icons/google_maps.png | Bin 0 -> 2153 bytes .../custom/Toolkits/toolkits-config.ts | 19 ++- 13 files changed, 346 insertions(+), 5 deletions(-) create mode 100644 pages/toolkits/search/google_maps.mdx rename pages/toolkits/{development/search.mdx => search/google_search.mdx} (100%) create mode 100644 pages/toolkits/search/reference.mdx create mode 100644 public/examples/integrations/toolkits/search/get_directions_between_addresses_example_call_tool.js create mode 100644 public/examples/integrations/toolkits/search/get_directions_between_addresses_example_call_tool.py create mode 100644 public/examples/integrations/toolkits/search/get_directions_between_addresses_example_llm_oai.js create mode 100644 public/examples/integrations/toolkits/search/get_directions_between_addresses_example_llm_oai.py create mode 100644 public/examples/integrations/toolkits/search/get_directions_between_coordinates_example_call_tool.js create mode 100644 public/examples/integrations/toolkits/search/get_directions_between_coordinates_example_call_tool.py create mode 100644 public/examples/integrations/toolkits/search/get_directions_between_coordinates_example_llm_oai.js create mode 100644 public/examples/integrations/toolkits/search/get_directions_between_coordinates_example_llm_oai.py create mode 100644 public/images/icons/google_maps.png 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 0000000000000000000000000000000000000000..01fb5c76ef42f133675703f67dece5694b37c773 GIT binary patch literal 2153 zcmV-v2$uJWP)Px#L}ge>W=%~1DgXcg2mk?xX#fNO00031000^Q000001E2u_0{{R30RRC20H6W@ z1ONa40RR91P@n?<1ONa40RR91a{vGU0Jnh|n*aa@(@8`@RCod9oKI{NRUF4>w!4zH zi-a1fRDxoOXyO4)t3gfF0%}Tx15wLCJZLl?JgHI80~ZdOXgqQBqKO8nG0~F&X`+dm zw%SC9#)x82EOo(9TCjGzD)bDCHPV$l*&S|Ve;*@r&Y#K^z|u>rrGRyVKPYTqjUW1o7Wl7$CyJZXmQZDbQPmr zpTAl(k{h`bQ{aFagU3Uq21x?2`^Cx5w!oX=6QSM~!Q*`fIlu4tzRq!eAI3I1K$D7N z0Mg*Gez3+?BpN^)-~fmUJm}9BERZ>7Fw5E&yiHxjKXl_BI5>myB#=pgA-I3T1PZ!I zWF4ogzPR5kYSad3OLZ)HEO^YGE<`PWOATHYh{^z$Dm-0?N&uHSJROMA0GA6qRftlL zF+V?e{}eN9W1VmFXHEN+eauN!;MCST%bpjsK?0jMe_}e1$RG9{S0#zGyR(D>tMI_- z#Ka>izES$xgcl`nAV_4CcyMZKf5X$dNr=|rg#-r*vkOT|Xj;M|c)TI%a&`e8pKr5L zPE;UoAifPse0K8vKjZr`+OEM%%1NleH1)*|Vybcd)$KoZ|_hdSG2mAi7?<)4hA2WBIam13-2_XPpJ2`|zHOkn|nixrt{} z2T)giyg`7ta$)u&zb|dORp3Q=R0==x`Q-Tq*7g_Q53LGq1>wy_c$4D&@bL0MZvAJk zb)4aki?(H7vqWQ6_f7X!mDg-sEkO+RiJT#l*2EX5+axnRMAcy$$=lxq?^eq5wLs`BL> z!8TJOCOq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