ai-functions
Call AI like you'd talk to a colleague
npm install ai-functionsSay what you need. Get what you asked for.
import { ai, list, is } from 'ai-functions'
// Ask questions
const qualified = is`${lead} a good fit for enterprise?`
// Generate lists
const ideas = list`content topics for ${persona}`
// Get structured data through destructuring
const { summary, nextSteps } = ai`analyze ${salesCall}`Promise Pipelining
Chain without await:
const { score, reason } = ai`qualify ${lead}`
const email = ai`follow-up based on: ${reason}`
if (await score > 80) {
await send(await email)
}Batch Processing
Process arrays in one call:
const qualified = await list`leads`.map(lead => ({
lead,
fit: is`${lead} matches ${icp}?`,
action: ai`next step for ${lead}`,
}))Exports
| Export | Description |
|---|---|
ai | Flexible generation |
list | Generate arrays |
lists | Named lists |
is | Boolean questions |
write | Long-form content |
summarize | Condense text |
extract | Structured extraction |
code | Code generation |
decide | Pick best option |
research | Web research |
ask | Human input |
approve | Human approval |
Related
Was this page helpful?