UNPKG

@handit.ai/ai-wrapper

Version:

🤖 Intelligent AI execution system with built-in tracking, evaluation, and self-improvement capabilities. The complete AI intelligence platform for enterprise applications.

162 lines (129 loc) • 4.32 kB
# 🚀 Quick Start Guide ## Installation ```bash npm install @handit.ai/ai-wrapper npm install @handit.ai/node openai @google/generative-ai @anthropic-ai/sdk ``` ## Basic Setup ```javascript const { AIWrapper } = require('@handit.ai/ai-wrapper'); const aiWrapper = new AIWrapper({ handitApiKey: 'your-handit-api-key', openaiApiKey: 'your-openai-api-key', // optional googleApiKey: 'your-google-api-key', // optional anthropicApiKey: 'your-anthropic-key' // optional }); ``` ## 🎯 Key Methods (Choose Your Style) ### 1. `runSmartAgent()` - **Recommended for most use cases** **The flagship method** - Full AI intelligence with tracking and self-improvement. ```javascript const result = await aiWrapper.runSmartAgent({ agentName: 'customer-support', input: 'How can I return my order?', model: 'gpt-4' }); console.log(result.output); // ✅ Tracks everything automatically // ✅ Learns from this interaction // ✅ Improves future responses ``` ### 2. `runOptimizedAgent()` - **For performance-focused tasks** Google AI with optimization focus. ```javascript const result = await aiWrapper.runOptimizedAgent({ agentName: 'content-writer', input: 'Write an SEO blog post about renewable energy' }); // ✅ Optimized for quality and performance ``` ### 3. `runTrackedAgent()` - **For sensitive/compliance tasks** Anthropic Claude with enhanced safety tracking. ```javascript const result = await aiWrapper.runTrackedAgent({ agentName: 'legal-reviewer', input: 'Review this contract for compliance issues' }); // ✅ Enhanced safety and compliance tracking ``` ### 4. Provider-Specific Methods Direct control over AI provider. ```javascript // OpenAI await aiWrapper.runWithOpenAI({ agentName: 'assistant', input: 'Generate code', model: 'gpt-4' }); // Google AI await aiWrapper.runWithGoogle({ agentName: 'analyzer', input: 'Analyze data', model: 'gemini-pro' }); // Anthropic Claude await aiWrapper.runWithAnthropic({ agentName: 'reviewer', input: 'Review content', model: 'claude-3-sonnet-20240229' }); ``` ## 📊 What Each Method Does | Method | Provider | Focus | Best For | |--------|----------|-------|----------| | `runSmartAgent()` | OpenAI | **Intelligence** | General AI tasks, customer support, analysis | | `runOptimizedAgent()` | Google AI | **Performance** | Content generation, optimization tasks | | `runTrackedAgent()` | Anthropic | **Safety** | Code review, legal, compliance | | `runWithX()` | Specific | **Control** | When you need a specific provider | ## 🎨 Quick Examples ### Basic Customer Support ```javascript const support = await aiWrapper.runSmartAgent({ agentName: 'customer-support', input: 'My order is late, what should I do?' }); ``` ### Content Generation ```javascript const content = await aiWrapper.runOptimizedAgent({ agentName: 'blog-writer', input: 'Write about the future of AI in healthcare' }); ``` ### Code Review ```javascript const review = await aiWrapper.runTrackedAgent({ agentName: 'code-reviewer', input: 'function login(user, pass) { /* code here */ }' }); ``` ## 🔧 Environment Variables (Optional) ```bash HANDIT_API_KEY=your-handit-key OPENAI_API_KEY=your-openai-key GOOGLE_API_KEY=your-google-key ANTHROPIC_API_KEY=your-anthropic-key ``` ## 🎯 Result Structure All methods return: ```javascript { success: true, // boolean output: "AI response here", // string executionId: "unique-id", // string prompts: [...], // array of prompts used error: null // string if failed } ``` ## 🚀 Next Steps 1. **Start with `runSmartAgent()`** - it's the most intelligent option 2. **Set up your agents in handit** - create prompts for your use cases 3. **Check the analytics** - see how your AI is performing 4. **Read the [full documentation](./DOCUMENTATION.md)** for advanced features ## 💡 Pro Tips - Use descriptive `agentName` values like `'customer-support-billing'` - The system learns from every interaction automatically - Check the handit dashboard to see performance analytics - All executions are tracked - no additional setup needed! --- **Need more details?** See the [Complete Documentation](./DOCUMENTATION.md) for advanced features, best practices, and in-depth examples.