@flatfile/improv
Version:
A powerful TypeScript library for building AI agents with multi-threaded conversations, tool execution, and event handling capabilities
186 lines (146 loc) ⢠5.54 kB
Markdown
# Adoption Guide: Making @flatfile/improv More Accessible
## Current Challenges & Solutions
### š« Problem: High Barrier to Entry
**Current**: 400+ line examples, multiple API keys required
**Solution**: Zero-config examples with mock drivers
```typescript
// OLD: Complex setup
const agent = new Agent({
systemPrompt: "...",
tools: [complexTool1, complexTool2],
driver: new BedrockThreadDriver({ /* AWS credentials */ }),
evaluators: [evaluator1, evaluator2],
// ... more configuration
});
// NEW: Simple start
import { createQuickAgent } from '@flatfile/improv/quick';
const agent = createQuickAgent({
prompt: "You are a helpful assistant",
tools: ["calculator", "weather"] // Built-in tools
});
```
### š« Problem: No Web Framework Integration
**Current**: No React/Next.js examples
**Solution**: Framework-specific adapters and hooks
```typescript
// React Hook (like Vercel AI SDK)
import { useImprovAgent } from '@flatfile/improv/react';
function ChatBot() {
const { messages, sendMessage, isLoading } = useImprovAgent({
tools: ['weather', 'calculator'],
apiKey: process.env.OPENAI_API_KEY
});
return (
<div>
{messages.map(msg => <div key={msg.id}>{msg.content}</div>)}
<input onSubmit={(text) => sendMessage(text)} />
</div>
);
}
```
### š« Problem: Complex API Surface
**Current**: Need to understand Agents, Threads, Tools, Events
**Solution**: Higher-level abstractions
```typescript
// OLD: Verbose
const agent = new Agent({...});
const thread = agent.createThread({...});
await thread.send(new Message({...}));
// NEW: Simple
import { chat } from '@flatfile/improv/simple';
const response = await chat("What's the weather?", {
tools: ["weather"],
apiKey: process.env.OPENAI_API_KEY
});
```
## Integration Strategies
### 1. Vercel AI SDK Migration Path
```typescript
// Vercel AI SDK
import { openai } from '@ai-sdk/openai';
import { generateText, tool } from 'ai';
const weatherTool = tool({
description: 'Get weather',
parameters: z.object({ location: z.string() }),
execute: async ({ location }) => `Weather in ${location}`,
});
const result = await generateText({
model: openai('gpt-4'),
prompt: 'Weather in NYC?',
tools: { weather: weatherTool },
});
// Improv equivalent with migration helper
import { createCompatAgent } from '@flatfile/improv/compat';
const agent = createCompatAgent({
model: 'gpt-4',
provider: 'openai',
tools: { weather: weatherTool } // Same tool definition!
});
const result = await agent.generateText('Weather in NYC?');
```
### 2. Mastra-style Workflows
```typescript
// Mastra pattern
const workflow = {
steps: [
{ name: 'analyze', tool: 'analyzer' },
{ name: 'process', tool: 'processor' },
{ name: 'notify', tool: 'notifier' }
]
};
// Improv equivalent
import { createWorkflow } from '@flatfile/improv/workflow';
const workflow = createWorkflow()
.step('analyze', { tool: 'analyzer' })
.step('process', { tool: 'processor' })
.step('notify', { tool: 'notifier' });
await workflow.execute(input);
```
## Recommended Package Structure
```
@flatfile/improv
āāā /core # Current core functionality
āāā /simple # High-level simple API
āāā /react # React hooks and components
āāā /nextjs # Next.js specific utilities
āāā /workflow # Workflow orchestration helpers
āāā /compat # Compatibility with other frameworks
āāā /templates # Pre-built agent templates
āāā /quick # Zero-config quick start
```
## Implementation Priorities
### Phase 1: Quick Wins (1-2 weeks)
1. **Zero-config examples** - Add mock drivers and built-in tools
2. **Simple API layer** - High-level functions that hide complexity
3. **Migration guides** - Documentation for Vercel AI SDK users
4. **Template gallery** - Copy-paste ready examples
### Phase 2: Framework Integration (2-4 weeks)
1. **React hooks** - `useImprovAgent`, `useImprovChat`
2. **Next.js utilities** - API route helpers, streaming support
3. **Compatibility layer** - Drop-in replacement for other frameworks
4. **Enhanced tooling** - CLI for project scaffolding
### Phase 3: Advanced Features (4-8 weeks)
1. **Visual workflow builder** - GUI for agent configuration
2. **Agent marketplace** - Shareable agent templates
3. **Cloud deployment** - One-click deployment options
4. **Monitoring dashboard** - Real-time agent performance
## Success Metrics
### Developer Experience
- **Time to first working agent**: < 5 minutes
- **Setup complexity**: Single command (`npm create improv-agent`)
- **Example clarity**: Working examples without API keys
### Adoption Indicators
- **GitHub stars growth**: Target 50% increase in 3 months
- **NPM downloads**: Track weekly active installations
- **Community engagement**: Issues, PRs, discussions
### Competitive Position
- **Feature parity**: Match Vercel AI SDK ergonomics
- **Unique value**: Event-driven architecture, multi-threading
- **Migration ease**: < 1 hour from competitors
## Next Steps
1. **Validate approach** - Test simplified APIs with beta users
2. **Create prototypes** - Build React hook and simple API prototypes
3. **Gather feedback** - Community input on API design
4. **Iterate rapidly** - Weekly releases with improvements
5. **Document extensively** - Clear guides for each use case
The goal is making improv as easy to adopt as Vercel AI SDK while maintaining its unique advantages in event-driven architecture and advanced agent capabilities.