Function: mapBot()
mapBot<
TInput,TOutput>(config):Processable<TInput,TOutput>
Defined in: packages/core/src/pipeline/helpers.ts:488
Create a step that maps a bot over an array (like Array.map but with LLMs). Applies the bot to each element and returns transformed array.
Type Parameters
TInput
TInput
Input type (object with array field or array itself)
TOutput
TOutput
Output type after mapping
Parameters
config
MapBotConfig<TInput, TOutput>
Configuration object with bot and array handling options
Returns
Processable<TInput, TOutput>
Processable that performs the mapping
Example
const enrichPostBot = Baleybot.create({
name: 'enrichPost',
model: openai('gpt-4o-mini'),
goal: 'Add SEO metadata to blog post',
output: Output.object({ schema: z.object({
title: z.string(),
description: z.string(),
keywords: z.array(z.string())
}) })
});
// Map over array field in object
const enrichPosts = pipeline(
loadBlogData,
mapBot({
bot: enrichPostBot,
arrayField: 'posts',
outputField: 'enrichedPosts',
parallel: true
}),
saveBlogData
);
// Map over array directly
const processList = pipeline(
loadItems,
mapBot({
bot: processItemBot,
parallel: true
}),
saveResults
);
// Sequential processing (for rate limiting)
const processSequentially = pipeline(
loadData,
mapBot({
bot: expensiveBot,
parallel: false // Process one at a time
})
);