# Creating AI Agents with Eliza --- Table of Contents: [TOC] ## Introduction _Duration: 2-3 minutes_ Eliza is a powerful multi-agent simulation framework designed to create, deploy, and manage autonomous AI agents. Built with TypeScript, it provides a flexible and extensible platform for developing intelligent agents that can interact across multiple platforms while maintaining consistent personalities and knowledge. ### Key Features - Multi-Agent Architecture - Character System - Memory Management - Platform Integration - Plugin System ## Setup & Prerequisites _Duration: 3-4 minutes_ ### Required Software - Node.js 23+ - pnpm - Python 2.7+ (if needed) - WSL 2 (for Windows users) ### Initial Setup Clone the starter repository ```bash git clone https://github.com/ai16z/eliza-starter.git ``` Install dependencies and start ```bash pnpm i && pnpm build && pnpm start ``` ## Creating Your First Agent _Duration: 8-10 minutes_ ### Character Configuration 1. Create a new character file 2. Define basic personality traits 3. Set up model preferences 4. Configure platform connections ### Basic Configuration Example ```typescript const myAgent = { name: "MyFirstAgent", personality: { traits: ["helpful", "friendly", "knowledgeable"], background: "An AI assistant focused on helping with technical tasks" }, modelConfig: { provider: "OPENAI", model: "gpt-4" } }; ``` ## Understanding Eliza Plugins _Duration: 3-4 minutes_ ### What are Plugins? Plugins are modular extensions that add new capabilities to your Eliza agent. Each plugin consists of three main components: 1. **Actions**: Specific tasks the agent can perform 2. **Evaluators**: Logic for assessing responses and behavior 3. **Providers**: Sources of information or services ### Plugin Architecture ```typescript interface Plugin { name: string; // Unique identifier for the plugin description: string; // Brief description of functionality actions?: Action[]; // Custom actions provided by plugin evaluators?: Evaluator[]; // Response evaluation logic providers?: Provider[]; // Information/service providers } ``` ### How Plugins Work 1. **Registration**: Plugins are registered when configuring your agent 2. **Discovery**: The agent automatically discovers available actions 3. **Execution**: Actions are triggered based on context and conversation 4. **Response**: Results are processed and returned to the conversation ### Common Plugin Types - **Integration Plugins**: Connect to external services (APIs, databases) - **Capability Plugins**: Add new functionalities (web search, image generation) - **Utility Plugins**: Provide helper functions and tools - **Platform Plugins**: Enable platform-specific features ### Plugin Development Flow 1. Create plugin structure 2. Define actions/evaluators/providers 3. Build and test locally 4. Package and distribute For example, here's a basic plugin structure: ```typescript // Basic plugin template const myPlugin: Plugin = { name: "my-plugin", description: "Adds custom functionality", actions: [ { name: "MY_ACTION", description: "Performs a specific task", handler: async (runtime, message) => { // Implementation } } ] }; ``` ## Adding Plugins - Web Search Example _Duration: 10-12 minutes_ ### Plugin Installation ```bash pnpm add @ai16z/plugin-web-search ``` ### Plugin Configuration ```typescript const myAgent = { plugins: ["@ai16z/plugin-web-search"] }; ``` ### Web Search Plugin Structure ```typescript import { Action, Plugin } from "@ai16z/eliza"; const webSearch: Action = { name: "WEB_SEARCH", similes: [ "SEARCH_WEB", "INTERNET_SEARCH", "LOOKUP", "QUERY_WEB" ], description: "Perform a web search to find information related to the message.", validate: async (runtime, message) => { return !!runtime.getSetting("TAVILY_API_KEY"); }, handler: async (runtime, message, state, options, callback) => { // Implementation details } }; export const webSearchPlugin: Plugin = { name: "webSearch", description: "Search web", actions: [webSearch], evaluators: [], providers: [] }; ``` ### Configuration Steps 1. Add API keys to .env file: ``` TAVILY_API_KEY=your_api_key_here ``` 2. Register plugin in your agent configuration: ```typescript import { webSearchPlugin } from "@ai16z/plugin-web-search"; const agentConfig = { // ... other config plugins: [webSearchPlugin] }; ``` ### Testing Web Search Example interactions: ```typescript // Example search queries [ { user: "user1", content: { text: "Find the latest news about SpaceX launches." } }, { user: "agentName", content: { text: "Here is the latest news about SpaceX launches:", action: "WEB_SEARCH" } } ] ``` ## Advanced Features _Duration: 5-6 minutes_ ### Memory Management - Conversation history - Knowledge base - Context awareness ### Multi-platform Support - Discord integration - Twitter integration - Telegram support ### Custom Actions and Providers ```typescript const customAction: Action = { name: "CUSTOM_ACTION", description: "Description of your custom action", handler: async (runtime, message) => { // Implementation } }; ``` ## Best Practices & Tips _Duration: 3-4 minutes_ ### Character File Organization - Keep configurations modular - Use clear naming conventions - Separate concerns appropriately ### Plugin Development Guidelines - Follow TypeScript best practices - Implement proper error handling - Document your code thoroughly ### Security Considerations - Protect API keys - Validate user inputs - Monitor resource usage ## Conclusion & Next Steps _Duration: 2-3 minutes_ ### Resources - [Official Documentation](https://ai16z.github.io/eliza/) - [GitHub Repository](https://github.com/ai16z/eliza) - [Discord Community](https://discord.gg/ai16z) ### Further Learning - Advanced plugin development - Custom model integration - Platform-specific optimizations ## Video Timestamps - 0:00 - Introduction - 2:30 - Setup & Prerequisites - 5:30 - Creating Your First Agent - 13:30 - Adding Plugins - 23:30 - Advanced Features - 28:30 - Best Practices - 31:30 - Conclusion ## Troubleshooting Common Issues 1. Installation Problems - Check Node.js version - Verify pnpm installation - Confirm environment variables 2. Plugin Issues - Verify API keys - Check plugin compatibility - Review error logs 3. Runtime Errors - Monitor memory usage - Check network connectivity - Validate configuration files