codev / src /tools /LocationTool /prompt.ts
chenbhao's picture
Add inline image utilities and integrate image handling into Location, WebFetch, and WebSearch tools.
8ed2aac
Raw
History Blame Contribute Delete
3.45 kB
export const LOCATION_TOOL_NAME = 'LocationTool'
export const PROMPT = `
LocationTool β€” Search geographic information, points of interest, and plan routes/travel.
This tool provides location-based services using two map providers:
- **ι«˜εΎ·εœ°ε›Ύ (Amap)**: Used for China mainland locations (cities, POIs, routes within China)
- **Google Maps**: Used for non-China mainland locations (international cities, cross-country routes)
**Capabilities:**
1. **Locate** β€” Detect the user's current location using Wi‑Fi fingerprinting (Amap for China, Google for abroad). If Wi‑Fi data unavailable, falls back to IP geolocation. Use \`action: "locate"\` without \`location\`.
2. **Geocoding** β€” Convert a place name to coordinates (latitude/longitude)
3. **Search Places** β€” Find nearby or in-city points of interest (restaurants, attractions, hotels, shopping, transportation, etc.)
4. **Get Directions** β€” Get routes between two locations with multiple transport modes (driving, walking, transit, bicycling)
5. **Plan Trip** β€” Multi-stop travel planning between cities/countries
**When to use this tool:**
- User asks "where am I?" β†’ use the \`locate\` action
- User asks about places, POIs, or things to do in a specific city/area
- User needs directions or route information between locations
- User wants to plan travel between cities or countries
- User asks about geographic coordinates of a place
**Combining with other tools:**
- After getting place/POI results from LocationTool, you can use **WebSearchTool** to search for travel guides, reviews, or additional information about specific places
- Use **WebFetchTool** to fetch detailed information from URLs found in search results (e.g., attraction pages, hotel booking sites, travel blog posts)
- **ImageShowTool**: When place results include photo URLs, the tool will automatically display images inline in the terminal. You can also explicitly call ImageShowTool with any image URL (local path or https:// URL) to display images.
- **Google Street View**: For any location (lat,lng), you can directly call ImageShowTool with a Google Street View Static API URL to display a street view panorama:
- URL format: \`https://maps.googleapis.com/maps/api/streetview?size=800x400&location=<lat>,<lng>&heading=0&pitch=0&key=<YOUR_API_KEY>\`
- Note: The free tier of Google Street View Static API requires an API key but has generous quotas
- Use this when users ask for "street view" or "θ‘—ζ™―" of a location
- Example: Search places β†’ WebSearch for reviews β†’ WebFetch for detailed info β†’ ImageShow for photos β†’ ImageShow with Google Street View URL for street panoramas
**Transport modes for directions:**
- For China (Amap): "driving", "walking", "transit" (ε…¬δΊ€/εœ°ι“)
- For international (Google): "driving", "walking", "transit", "bicycling"
**API Keys:**
- \`AMAP_API_KEY\` env var β€” required for China mainland queries
- \`GOOGLE_MAPS_API_KEY\` env var β€” required for non-China queries
**Coordinate input:**
- You can pass \`location\` as "lat,lng" coordinates (e.g. \`"34.2583,108.9286"\`) to search/directions directly by coordinates, bypassing geocoding
- Region is auto-detected from coordinates using China's bounding box
**Region auto-detection:**
- Locations containing Chinese characters or recognized Chinese city names β†’ uses Amap
- Other locations β†’ uses Google Maps
- You can also explicitly specify the \`region\` parameter
`