Skip to content

Documentation v1.0.0


Documentation / @openassistant/osm / getUsCityGeojson

Variable: getUsCityGeojson

const getUsCityGeojson: OpenAssistantTool<typeof getUsCityGeojsonParameters, GetUsCityGeojsonLlmResult, GetUsCityGeojsonAdditionalData, object>

Defined in: us/city.ts:87

getUsCityGeojson Tool

This tool can be used to get the GeoJSON data of one or more United States cities using the Github repository: https://github.com/generalpiston/geojson-us-city-boundaries

INFO

to avoid overloading the Github API, we only fetch the GeoJSON data every 1 second.

Example user prompts:

  • "Get the city boundaries for San Francisco, CA"
  • "Get city data for Chandler, AZ"
  • "What are the boundaries of Los Angeles?"

TIP

This tool can be mixed with other tools for more complex tasks. For example, if you have a point datasets, you can use this tool to answer questions like "What are the total revenues in the cities of California?"

Example

typescript
import { getUsCityGeojson, GetUsCityGeojsonTool } from "@openassistant/osm";
import { convertToVercelAiTool, ToolCache } from '@openassistant/utils';
import { generateText } from 'ai';

// you can use ToolCache to save the city geojson dataset for later use
const toolResultCache = ToolCache.getInstance();

const cityTool: GetUsCityGeojsonTool = {
  ...getUsCityGeojson,
  onToolCompleted: (toolCallId, additionalData) => {
    toolResultCache.addDataset(toolCallId, additionalData);
  },
};

generateText({
  model: openai('gpt-4.1', { apiKey: key }),
  prompt: 'What are the boundaries of San Francisco?',
  tools: {
    city: convertToVercelAiTool(cityTool),
  },
});

Released under the MIT License.