Documentation / @openassistant/map / downloadMapData
Variable: downloadMapData
constdownloadMapData:OpenAssistantTool<typeofdownloadMapDataParameters,DownloadMapLlmResult,DownloadMapAdditionalData,MapToolContext>
Defined in: data/tool.ts:77
The downloadMapData tool is used to download map data (GeoJson or CSV) from a url.
TIP
Use this tool to download map data, you can cache the dataset in onToolCompleted() callback. Other tools e.g. keplergl can use the downloaded dataset to create a map, or query the downloaded dataset using localQuery tool.
Example
typescript
import { downloadMapData, keplergl } from '@openassistant/map';
import { convertToVercelAiTool, ToolCache } from '@openassistant/utils';
import { generateText } from 'ai';
const toolResultCache = ToolCache.getInstance();
const downloadMapTool = {
...downloadMapData,
onToolCompleted: (toolCallId: string, additionalData?: unknown) => {
toolResultCache.addDataset(toolCallId, additionalData);
},
};
const keplerglTool = {
...keplergl,
context: {
getDataset: async (datasetName: string) => {
// find dataset based on datasetName first
// return MYDATASETS[datasetName];
// if no dataset is found, check if dataset is in toolResultCache
if (toolResultCache.hasDataset(datasetName)) {
return toolResultCache.getDataset(datasetName);
}
throw new Error(`Dataset ${datasetName} not found`);
},
},
};
* generateText({
model: openai('gpt-4.1', { apiKey: key }),
prompt: 'Create a from https://geodacenter.github.io/data-and-lab//data/Chi_Carjackings.geojson',
tools: {
createMap: convertToVercelAiTool(keplerglTool),
downloadMapData: convertToVercelAiTool(downloadMapTool),
},
});