Functions.do  Strongly-Typed AI Functions
AI is transforming businesses but integrating LLMs into existing systems presents challenges due to the clash between AI’s non-deterministic nature and traditional software’s deterministic characteristics.
Key challenges include:
- Reliability: AI’s unpredictable outputs complicate testing and maintenance
- Accuracy: Models can hallucinate or produce incorrect information
- Model Selection: Balancing capabilities, speed, and cost across rapidly evolving models
- Prompt Engineering: More art than science, difficult to standardize
- Configuration: Complex parameter interactions require careful tuning
The Solution
functions.do creates a clean separation between AI capabilities and application code through strongly-typed interfaces that hide model complexities, enabling:
- Rapid prototyping of AI applications
- Continuous improvement without disrupting application code
- Comprehensive evaluation and optimization strategies
Installation
npm install functions.do
# or
yarn add functions.do
# or
pnpm add functions.do
API Overview
The functions.do SDK exports two main components:
ai
: A flexible proxy for invoking AI functions with various patternsAI
: A function for defining schemas and creating custom AI functions
Rapid Prototyping
The ai
object lets you call any arbitrary function and an object will be returned. This can be very helpful during development or to even just see what is the schema that the AI wants to return.
import { ai } from 'functions.do'
const titles = await ai.listBlogPostTitles({ topic: 'AGI Wrappers', tone: 'Clickbait Meme' })
const research = await ai.researchCompany({ company }, { model: 'perplexity/sonar-deep-research' }) // specify a particular model
Structured Outputs
We believe that your business and application code should not be complicated by the leaky abstractions of AI frameworks. With new models being released daily, you shouldn’t put the model, prompts, or settings in your code as the only thing that matters to your application is the return type of the output.
import { AI } from 'functions.do'
const ai = AI({
leanCanvas: {
productName: 'name of the product or service',
problem: ['top 3 problems the product solves'],
solution: ['top 3 solutions the product offers'],
uniqueValueProposition: 'clear message that states the benefit of your product',
unfairAdvantage: 'something that cannot be easily copied or bought',
customerSegments: ['list of target customer segments'],
keyMetrics: ['list of key numbers that tell you how your business is doing'],
channels: ['path to customers'],
costStructure: ['list of operational costs'],
revenueStreams: ['list of revenue sources'],
recommendations: ['list of recommendations based on the analysis'],
},
})
const brand = await ai.storyBrand({
idea: 'Agentic Workflow Platform',
icp: 'Alpha Devs & Empowered CTOs',
})
console.log(brand)
// {
// storyBrand: {
// hero: {
// identity: 'Alpha developers and empowered CTOs',
// desire: 'To effortlessly build and deploy intelligent, scalable, agent-driven workflows'
// },
// problem: {
// external: 'Current workflow solutions lack flexibility, autonomy, and speed.',
// internal: 'Frustrated by bottlenecks, repetitive tasks, and slow development cycles.',
// philosophical: 'Innovative developers and CTOs deserve tools designed to empower, not constrain.',
// villain: 'Leaky abstractions',
// },
// // ... additional output omitted for brevity
// }
// }