d25d482dc2
Publish CLI Package / publish-npm (push) Waiting to run
Publish Python SDK / publish-pypi (push) Waiting to run
Publish TypeScript SDK / publish-npm (push) Waiting to run
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
195 lines
5.8 KiB
TypeScript
195 lines
5.8 KiB
TypeScript
import type {
|
|
GoogleMapsPlacesSearchParams,
|
|
GoogleMapsPlacesSearchResponse,
|
|
} from '@/tools/google_maps/types'
|
|
import type { ToolConfig } from '@/tools/types'
|
|
|
|
export const googleMapsPlacesSearchTool: ToolConfig<
|
|
GoogleMapsPlacesSearchParams,
|
|
GoogleMapsPlacesSearchResponse
|
|
> = {
|
|
id: 'google_maps_places_search',
|
|
name: 'Google Maps Places Search',
|
|
description: 'Search for places using a text query',
|
|
version: '1.0.0',
|
|
|
|
params: {
|
|
apiKey: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-only',
|
|
description: 'Google Maps API key',
|
|
},
|
|
query: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-or-llm',
|
|
description: 'Search query (e.g., "restaurants in Times Square")',
|
|
},
|
|
location: {
|
|
type: 'json',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Location to bias results towards ({lat, lng})',
|
|
},
|
|
radius: {
|
|
type: 'number',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Search radius in meters',
|
|
},
|
|
type: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Place type filter (e.g., restaurant, cafe, hotel)',
|
|
},
|
|
language: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Language code for results (e.g., en, es, fr)',
|
|
},
|
|
region: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Region bias as a ccTLD code (e.g., us, uk)',
|
|
},
|
|
pageToken: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description:
|
|
'Token from a previous search response to fetch the next page of results. Wait a couple seconds after receiving the token before using it, or the API returns INVALID_REQUEST',
|
|
},
|
|
},
|
|
|
|
hosting: {
|
|
envKeyPrefix: 'GOOGLE_CLOUD_API_KEY',
|
|
apiKeyParam: 'apiKey',
|
|
byokProviderId: 'google_cloud',
|
|
pricing: {
|
|
type: 'per_request',
|
|
cost: 0.032,
|
|
},
|
|
rateLimit: {
|
|
mode: 'per_request',
|
|
requestsPerMinute: 60,
|
|
},
|
|
},
|
|
|
|
request: {
|
|
url: (params) => {
|
|
const url = new URL('https://maps.googleapis.com/maps/api/place/textsearch/json')
|
|
url.searchParams.set('query', params.query.trim())
|
|
url.searchParams.set('key', params.apiKey.trim())
|
|
|
|
if (params.location) {
|
|
url.searchParams.set('location', `${params.location.lat},${params.location.lng}`)
|
|
}
|
|
if (params.radius) {
|
|
url.searchParams.set('radius', params.radius.toString())
|
|
}
|
|
if (params.type) {
|
|
url.searchParams.set('type', params.type)
|
|
}
|
|
if (params.language) {
|
|
url.searchParams.set('language', params.language.trim())
|
|
}
|
|
if (params.region) {
|
|
url.searchParams.set('region', params.region.trim())
|
|
}
|
|
if (params.pageToken) {
|
|
url.searchParams.set('pagetoken', params.pageToken.trim())
|
|
}
|
|
|
|
return url.toString()
|
|
},
|
|
method: 'GET',
|
|
headers: () => ({
|
|
'Content-Type': 'application/json',
|
|
}),
|
|
},
|
|
|
|
transformResponse: async (response: Response) => {
|
|
const data = await response.json()
|
|
|
|
if (data.status !== 'OK' && data.status !== 'ZERO_RESULTS') {
|
|
throw new Error(
|
|
`Places search failed: ${data.status} - ${data.error_message || 'Unknown error'}`
|
|
)
|
|
}
|
|
|
|
const places = (data.results || []).map(
|
|
(place: {
|
|
place_id: string
|
|
name: string
|
|
formatted_address: string
|
|
geometry: { location: { lat: number; lng: number } }
|
|
types: string[]
|
|
rating?: number
|
|
user_ratings_total?: number
|
|
price_level?: number
|
|
opening_hours?: { open_now: boolean }
|
|
photos?: Array<{ photo_reference: string; height: number; width: number }>
|
|
business_status?: string
|
|
}) => ({
|
|
placeId: place.place_id,
|
|
name: place.name,
|
|
formattedAddress: place.formatted_address,
|
|
lat: place.geometry.location.lat,
|
|
lng: place.geometry.location.lng,
|
|
types: place.types ?? [],
|
|
rating: place.rating ?? null,
|
|
userRatingsTotal: place.user_ratings_total ?? null,
|
|
priceLevel: place.price_level ?? null,
|
|
openNow: place.opening_hours?.open_now ?? null,
|
|
photoReference: place.photos?.[0]?.photo_reference ?? null,
|
|
businessStatus: place.business_status ?? null,
|
|
})
|
|
)
|
|
|
|
return {
|
|
success: true,
|
|
output: {
|
|
places,
|
|
nextPageToken: data.next_page_token ?? null,
|
|
},
|
|
}
|
|
},
|
|
|
|
outputs: {
|
|
places: {
|
|
type: 'array',
|
|
description: 'List of places found',
|
|
items: {
|
|
type: 'object',
|
|
properties: {
|
|
placeId: { type: 'string', description: 'Google Place ID' },
|
|
name: { type: 'string', description: 'Place name' },
|
|
formattedAddress: { type: 'string', description: 'Formatted address' },
|
|
lat: { type: 'number', description: 'Latitude' },
|
|
lng: { type: 'number', description: 'Longitude' },
|
|
types: { type: 'array', description: 'Place types' },
|
|
rating: { type: 'number', description: 'Average rating (1-5)', optional: true },
|
|
userRatingsTotal: { type: 'number', description: 'Number of ratings', optional: true },
|
|
priceLevel: { type: 'number', description: 'Price level (0-4)', optional: true },
|
|
openNow: { type: 'boolean', description: 'Whether currently open', optional: true },
|
|
photoReference: {
|
|
type: 'string',
|
|
description: 'Photo reference for Photos API',
|
|
optional: true,
|
|
},
|
|
businessStatus: { type: 'string', description: 'Business status', optional: true },
|
|
},
|
|
},
|
|
},
|
|
nextPageToken: {
|
|
type: 'string',
|
|
description: 'Token for fetching the next page of results',
|
|
optional: true,
|
|
},
|
|
},
|
|
}
|