콘텐츠로 이동

CrewAI 다중 에이전트 프레임워크 치트 시트

개요

CrewAI는 개발자가 AI 기반 애플리케이션을 구축하고 배포하는 방식을 혁신하는 오픈 소스 다중 에이전트 오케스트레이션 프레임워크입니다. 주앙 무라(João Moura)가 만든 이 Python 기반 프레임워크는 여러 AI 에이전트가 특정 역할을 맡고 책임을 공유하면서 단일 에이전트가 혼자 처리하기 어려운 복잡한 작업을 수행할 수 있도록 합니다.

CrewAI의 차별점은 에이전트가 서로에게 작업을 자율적으로 위임하고, 문제 해결에 협력하며, 특수한 도구와 기능을 활용할 수 있는 정교한 다중 에이전트 시스템을 오케스트레이션할 수 있는 능력입니다. 이 프레임워크는 빠른 개발을 위한 높은 수준의 단순성과 복잡한 시나리오를 위한 정밀한 저수준 제어를 모두 제공하여, 모든 비즈니스 또는 기술적 요구에 맞춘 자율적인 AI 에이전트를 만드는 데 이상적입니다.

CrewAI는 다면적인 도전 과제를 관리할 수 있는 AI 시스템에 대한 증가하는 필요성을 해결하며, 이를 관리 가능한 구성 요소로 분해하고, 각 구성 요소에 특화된 에이전트를 할당하며, 전통적인 단일 에이전트 접근 방식보다 우수한 결과를 달성하기 위해 그들의 노력을 조정합니다.

핵심 개념

에이전트

에이전트는 CrewAI 시스템의 기본 구성 요소입니다. 각 에이전트는 특정 역할, 목표, 그리고 기능을 가지고 설계되어, 자신의 전문 영역 내에서 추론하고, 계획하며, 작업을 실행할 수 있는 자율적인 개체로 기능합니다.

크루(Crews)

크루는 공통된 목표를 향해 함께 작업하는 에이전트들의 모음입니다. 크루는 다중 에이전트 협업의 구조와 워크플로우를 정의하고, 에이전트가 어떻게 상호작용하고, 작업을 위임하며, 정보를 공유할지 설정합니다.

작업

작업은 완료해야 할 특정 목표 또는 활동을 나타냅니다. 복잡성과 요구 사항에 따라 개별 에이전트에게 할당되거나 크루 내의 여러 에이전트에 분산될 수 있습니다.

도구

도구는 외부 서비스, API, 데이터베이스 또는 특수 기능에 대한 접근을 제공함으로써 에이전트의 기능을 확장합니다. 에이전트는 도구를 사용하여 핵심 언어 모델 기능 이상의 작업을 수행할 수 있습니다.

Would you like me to continue with the remaining sections?```bash

Install CrewAI using pip

pip install crewai

Install with additional tools

pip install ‘crewai[tools]‘

Install development version

pip install git+https://github.com/crewAIInc/crewAI.git


### Environment Setup
```python
import os
from crewai import Agent, Task, Crew, Process

# Set up API keys for LLM providers
os.environ["OPENAI_API_KEY"] = "your-openai-api-key"
# or
os.environ["ANTHROPIC_API_KEY"] = "your-anthropic-api-key"
# or other supported providers

Project Structure

my_crew_project/
├── agents/
│   ├── __init__.py
│   ├── researcher.py
│   └── writer.py
├── tasks/
│   ├── __init__.py
│   ├── research_tasks.py
│   └── writing_tasks.py
├── tools/
│   ├── __init__.py
│   └── custom_tools.py
├── crews/
│   ├── __init__.py
│   └── content_crew.py
└── main.py

Agent Configuration

Basic Agent Creation

from crewai import Agent

# Create a basic agent
researcher = Agent(
    role='Research Specialist',
    goal='Conduct thorough research on given topics',
    backstory="""You are an experienced researcher with expertise in
    gathering, analyzing, and synthesizing information from multiple sources.
    You have a keen eye for detail and can identify reliable sources.""",
    verbose=True,
    allow_delegation=False
)

Advanced Agent Configuration

from crewai import Agent
from crewai_tools import SerperDevTool, WebsiteSearchTool

# Create an agent with tools and advanced settings
research_agent = Agent(
    role='Senior Research Analyst',
    goal='Provide comprehensive analysis and insights on market trends',
    backstory="""You are a senior research analyst with 10+ years of experience
    in market research and competitive analysis. You excel at identifying patterns,
    trends, and actionable insights from complex data sets.""",
    tools=[SerperDevTool(), WebsiteSearchTool()],
    verbose=True,
    allow_delegation=True,
    max_iter=5,
    memory=True,
    step_callback=lambda step: print(f"Agent step: \\\\{step\\\\}"),
    system_template="""You are \\\\{role\\\\}. \\\\{backstory\\\\}
    Your goal is: \\\\{goal\\\\}
    Always provide detailed analysis with supporting evidence."""
)

Agent with Custom LLM

from langchain.llms import OpenAI
from crewai import Agent

# Use custom LLM configuration
custom_llm = OpenAI(temperature=0.7, model_name="gpt-4")

analyst = Agent(
    role='Data Analyst',
    goal='Analyze data and provide statistical insights',
    backstory='Expert in statistical analysis and data interpretation',
    llm=custom_llm,
    verbose=True
)

Multimodal Agent

from crewai import Agent

# Agent with multimodal capabilities
visual_analyst = Agent(
    role='Visual Content Analyst',
    goal='Analyze images and visual content for insights',
    backstory='Specialist in visual content analysis and interpretation',
    multimodal=True,  # Enable multimodal capabilities
    tools=[image_analysis_tool],
    verbose=True
)

Task Definition and Management

Basic Task Creation

from crewai import Task

# Define a simple task
research_task = Task(
    description="""Conduct comprehensive research on artificial intelligence
    trends in 2024. Focus on:
    1. Emerging AI technologies
    2. Market adoption rates
    3. Key industry players
    4. Future predictions

    Provide a detailed report with sources and citations.""",
    agent=researcher,
    expected_output="A comprehensive research report with citations"
)

Advanced Task Configuration

from crewai import Task

# Task with dependencies and callbacks
analysis_task = Task(
    description="""Analyze the research findings and create strategic
    recommendations for AI adoption in enterprise environments.""",
    agent=analyst,
    expected_output="Strategic recommendations document with actionable insights",
    context=[research_task],  # Depends on research_task completion
    callback=lambda output: save_to_database(output),
    async_execution=False,
    output_file="analysis_report.md"
)

Task with Custom Output Parsing

from crewai import Task
from pydantic import BaseModel
from typing import List

class ResearchOutput(BaseModel):
    title: str
    summary: str
    key_findings: List[str]
    sources: List[str]
    confidence_score: float

structured_task = Task(
    description="Research AI market trends and provide structured output",
    agent=researcher,
    expected_output="Structured research findings",
    output_pydantic=ResearchOutput
)

Conditional Task Execution

from crewai import Task

def should_execute_task(context):
    # Custom logic to determine if task should execute
    return len(context.get('findings', [])) > 5

conditional_task = Task(
    description="Perform detailed analysis if sufficient data is available",
    agent=analyst,
    expected_output="Detailed analysis report",
    condition=should_execute_task
)

Crew Orchestration

Basic Crew Setup

from crewai import Crew, Process

# Create a basic crew
content_crew = Crew(
    agents=[researcher, writer],
    tasks=[research_task, writing_task],
    verbose=2,
    process=Process.sequential
)

# Execute the crew
result = content_crew.kickoff()
print(result)

Advanced Crew Configuration

from crewai import Crew, Process
from crewai.memory import LongTermMemory

# Advanced crew with memory and custom settings
advanced_crew = Crew(
    agents=[researcher, analyst, writer, reviewer],
    tasks=[research_task, analysis_task, writing_task, review_task],
    process=Process.hierarchical,
    memory=LongTermMemory(),
    verbose=2,
    manager_llm=manager_llm,
    function_calling_llm=function_llm,
    max_rpm=10,
    share_crew=True,
    step_callback=crew_step_callback,
    task_callback=crew_task_callback
)

Hierarchical Process

from crewai import Crew, Process, Agent

# Manager agent for hierarchical process
manager = Agent(
    role='Project Manager',
    goal='Coordinate team activities and ensure quality deliverables',
    backstory='Experienced project manager with strong leadership skills',
    allow_delegation=True
)

hierarchical_crew = Crew(
    agents=[manager, researcher, analyst, writer],
    tasks=[research_task, analysis_task, writing_task],
    process=Process.hierarchical,
    manager_agent=manager,
    verbose=2
)

Parallel Task Execution

from crewai import Crew, Process

# Crew with parallel task execution
parallel_crew = Crew(
    agents=[researcher1, researcher2, researcher3],
    tasks=[task1, task2, task3],
    process=Process.sequential,  # Overall sequential, but tasks can run in parallel
    max_execution_time=3600,  # 1 hour timeout
    verbose=2
)

# Execute with parallel capabilities
result = parallel_crew.kickoff(inputs=\\\\{
    'topic': 'AI in Healthcare',
    'deadline': '2024-12-31'
\\\\})

Tool Integration

Built-in Tools

from crewai_tools import (
    SerperDevTool,
    WebsiteSearchTool,
    FileReadTool,
    DirectoryReadTool,
    CodeDocsSearchTool,
    YoutubeVideoSearchTool
)

# Configure built-in tools
search_tool = SerperDevTool()
web_tool = WebsiteSearchTool()
file_tool = FileReadTool()
code_tool = CodeDocsSearchTool()

# Agent with multiple tools
multi_tool_agent = Agent(
    role='Research Assistant',
    goal='Gather information from multiple sources',
    backstory='Versatile researcher with access to various information sources',
    tools=[search_tool, web_tool, file_tool, code_tool],
    verbose=True
)

Custom Tool Development

from crewai_tools import BaseTool
from typing import Type
from pydantic import BaseModel, Field

class DatabaseQueryInput(BaseModel):
    query: str = Field(description="SQL query to execute")
    database: str = Field(description="Database name")

class DatabaseQueryTool(BaseTool):
    name: str = "Database Query Tool"
    description: str = "Execute SQL queries against specified databases"
    args_schema: Type[BaseModel] = DatabaseQueryInput

    def _run(self, query: str, database: str) -> str:
        # Implement database query logic
        try:
            # Connect to database and execute query
            result = execute_database_query(database, query)
            return f"Query executed successfully: \\\\{result\\\\}"
        except Exception as e:
            return f"Query failed: \\\\{str(e)\\\\}"

# Use custom tool
db_tool = DatabaseQueryTool()
database_agent = Agent(
    role='Database Analyst',
    goal='Query and analyze database information',
    backstory='Expert in database operations and SQL',
    tools=[db_tool],
    verbose=True
)

API Integration Tool

from crewai_tools import BaseTool
import requests

class APIIntegrationTool(BaseTool):
    name: str = "API Integration Tool"
    description: str = "Make HTTP requests to external APIs"

    def _run(self, endpoint: str, method: str = "GET", data: dict = None) -> str:
        try:
            if method.upper() == "GET":
                response = requests.get(endpoint)
            elif method.upper() == "POST":
                response = requests.post(endpoint, json=data)

            return response.json()
        except Exception as e:
            return f"API request failed: \\\\{str(e)\\\\}"

# Agent with API capabilities
api_agent = Agent(
    role='API Integration Specialist',
    goal='Interact with external services via APIs',
    backstory='Expert in API integration and data retrieval',
    tools=[APIIntegrationTool()],
    verbose=True
)

Memory and Context Management

Long-Term Memory

from crewai.memory import LongTermMemory
from crewai import Crew

# Crew with persistent memory
memory_crew = Crew(
    agents=[researcher, analyst],
    tasks=[research_task, analysis_task],
    memory=LongTermMemory(),
    verbose=2
)

# Memory persists across executions
result1 = memory_crew.kickoff(inputs=\\\\{'topic': 'AI Ethics'\\\\})
result2 = memory_crew.kickoff(inputs=\\\\{'topic': 'AI Regulation'\\\\})

Context Sharing

from crewai import Task, Agent

# Tasks that share context
context_task1 = Task(
    description="Research market trends",
    agent=researcher,
    expected_output="Market trend analysis"
)

context_task2 = Task(
    description="Analyze the market trends and provide recommendations",
    agent=analyst,
    expected_output="Strategic recommendations",
    context=[context_task1]  # Uses output from context_task1
)
```### 맞춤형 메모리 구현
```python
from crewai.memory.entity.entity_memory import EntityMemory
from crewai.memory.long_term.long_term_memory import LongTermMemory

class CustomMemory(LongTermMemory):
    def __init__(self, storage_path: str = "./custom_memory"):
        super().__init__(storage_path=storage_path)
        self.custom_entities = \\\\{\\\\}

    def save_entity(self, entity_name: str, entity_data: dict):
        self.custom_entities[entity_name] = entity_data
        # Implement custom storage logic

    def retrieve_entity(self, entity_name: str) -> dict:
        return self.custom_entities.get(entity_name, \\\\{\\\\})

# Use custom memory
custom_memory = CustomMemory("./project_memory")
crew_with_custom_memory = Crew(
    agents=[researcher, analyst],
    tasks=[research_task, analysis_task],
    memory=custom_memory
)
```## 고급 기능

### 에이전트 위임
```python
from crewai import Agent

# Senior agent that can delegate
senior_researcher = Agent(
    role='Senior Research Director',
    goal='Oversee research projects and delegate tasks',
    backstory='Experienced research director with team management skills',
    allow_delegation=True,
    max_delegation=3,
    verbose=True
)

# Junior agents that can receive delegated tasks
junior_researcher1 = Agent(
    role='Junior Researcher - Technology',
    goal='Research technology trends and innovations',
    backstory='Specialized in technology research',
    allow_delegation=False
)

junior_researcher2 = Agent(
    role='Junior Researcher - Market Analysis',
    goal='Analyze market conditions and competitive landscape',
    backstory='Specialized in market research and analysis',
    allow_delegation=False
)

# Crew with delegation hierarchy
delegation_crew = Crew(
    agents=[senior_researcher, junior_researcher1, junior_researcher2],
    tasks=[complex_research_task],
    process=Process.hierarchical,
    verbose=2
)
```### 추론 및 계획
```python
from crewai import Agent

# Agent with enhanced reasoning capabilities
reasoning_agent = Agent(
    role='Strategic Planner',
    goal='Develop comprehensive strategies with detailed reasoning',
    backstory='Expert strategic planner with strong analytical skills',
    reasoning=True,  # Enable reasoning capabilities
    planning=True,   # Enable planning capabilities
    verbose=True,
    max_iter=10
)

# Task that requires complex reasoning
strategic_task = Task(
    description="""Develop a comprehensive 5-year strategic plan for AI adoption
    in the healthcare industry. Consider:
    1. Current market conditions
    2. Regulatory environment
    3. Technology readiness
    4. Competitive landscape
    5. Implementation challenges

    Provide detailed reasoning for each recommendation.""",
    agent=reasoning_agent,
    expected_output="Comprehensive strategic plan with detailed reasoning"
)
```### 콜백 및 모니터링
```python
from crewai import Crew, Agent, Task

def agent_step_callback(agent_output):
    print(f"Agent \\\\{agent_output.agent\\\\} completed step: \\\\{agent_output.step\\\\}")
    # Log to monitoring system
    log_agent_activity(agent_output)

def task_completion_callback(task_output):
    print(f"Task completed: \\\\{task_output.description\\\\}")
    # Send notification or update dashboard
    notify_task_completion(task_output)

def crew_step_callback(crew_output):
    print(f"Crew step completed: \\\\{crew_output\\\\}")
    # Update progress tracking
    update_progress(crew_output)

# Crew with comprehensive monitoring
monitored_crew = Crew(
    agents=[researcher, analyst, writer],
    tasks=[research_task, analysis_task, writing_task],
    step_callback=crew_step_callback,
    task_callback=task_completion_callback,
    verbose=2
)

# Agents with individual monitoring
monitored_agent = Agent(
    role='Monitored Researcher',
    goal='Conduct research with detailed monitoring',
    backstory='Researcher with comprehensive activity tracking',
    step_callback=agent_step_callback,
    verbose=True
)
```## 오류 처리 및 복원력

### 재시도 로직
```python
from crewai import Task, Agent
import time

def retry_callback(attempt, error):
    print(f"Task failed on attempt \\\\{attempt\\\\}: \\\\{error\\\\}")
    time.sleep(2 ** attempt)  # Exponential backoff

resilient_task = Task(
    description="Perform web research with retry logic",
    agent=researcher,
    expected_output="Research findings",
    max_retries=3,
    retry_callback=retry_callback
)
```### 오류 복구
```python
from crewai import Crew, Process

def error_handler(error, context):
    print(f"Error occurred: \\\\{error\\\\}")
    # Implement recovery logic
    if "rate_limit" in str(error).lower():
        time.sleep(60)  # Wait for rate limit reset
        return True  # Retry
    return False  # Don't retry

error_resilient_crew = Crew(
    agents=[researcher, analyst],
    tasks=[research_task, analysis_task],
    error_handler=error_handler,
    max_retries=3,
    verbose=2
)
```### 폴백 에이전트
```python
from crewai import Agent, Task, Crew

# Primary agent
primary_researcher = Agent(
    role='Primary Researcher',
    goal='Conduct comprehensive research',
    backstory='Expert researcher with specialized tools',
    tools=[advanced_search_tool, database_tool]
)

# Fallback agent with basic capabilities
fallback_researcher = Agent(
    role='Backup Researcher',
    goal='Conduct basic research when primary agent fails',
    backstory='Reliable researcher with basic tools',
    tools=[basic_search_tool]
)

# Task with fallback logic
research_with_fallback = Task(
    description="Conduct research with fallback support",
    agent=primary_researcher,
    fallback_agent=fallback_researcher,
    expected_output="Research findings"
)
```## 성능 최적화

### 병렬 실행
```python
from crewai import Crew, Process
import asyncio

# Async crew execution
async def run_crew_async():
    crew = Crew(
        agents=[researcher1, researcher2, researcher3],
        tasks=[task1, task2, task3],
        process=Process.sequential,
        verbose=2
    )

    result = await crew.kickoff_async(inputs=\\\\{'topic': 'AI Trends'\\\\})
    return result

# Run multiple crews in parallel
async def run_multiple_crews():
    crews = [create_crew(topic) for topic in ['AI', 'ML', 'NLP']]
    results = await asyncio.gather(*[crew.kickoff_async() for crew in crews])
    return results
```### 리소스 관리
```python
from crewai import Crew
import threading

class ResourceManager:
    def __init__(self, max_concurrent_agents=5):
        self.semaphore = threading.Semaphore(max_concurrent_agents)
        self.active_agents = 0

    def acquire_agent_slot(self):
        self.semaphore.acquire()
        self.active_agents += 1

    def release_agent_slot(self):
        self.semaphore.release()
        self.active_agents -= 1

resource_manager = ResourceManager(max_concurrent_agents=3)

# Crew with resource management
resource_managed_crew = Crew(
    agents=[researcher, analyst, writer],
    tasks=[research_task, analysis_task, writing_task],
    resource_manager=resource_manager,
    verbose=2
)
```### 캐싱 및 최적화
```python
from crewai import Agent, Task
from functools import lru_cache

# Agent with caching capabilities
class CachedAgent(Agent):
    @lru_cache(maxsize=100)
    def cached_execution(self, task_description):
        return super().execute_task(task_description)

cached_researcher = CachedAgent(
    role='Cached Researcher',
    goal='Perform research with caching',
    backstory='Efficient researcher with caching capabilities'
)

# Task with caching
cached_task = Task(
    description="Research AI trends (cached)",
    agent=cached_researcher,
    expected_output="Cached research results",
    cache_results=True
)
```## 통합 패턴

### Flask 웹 애플리케이션
```python
from flask import Flask, request, jsonify
from crewai import Crew, Agent, Task

app = Flask(__name__)

# Initialize crew components
researcher = Agent(
    role='API Researcher',
    goal='Research topics via web API',
    backstory='Researcher accessible via web API'
)

@app.route('/research', methods=['POST'])
def research_endpoint():
    data = request.json
    topic = data.get('topic')

    # Create dynamic task
    research_task = Task(
        description=f"Research the topic: \\\\{topic\\\\}",
        agent=researcher,
        expected_output="Research findings"
    )

    # Execute crew
    crew = Crew(agents=[researcher], tasks=[research_task])
    result = crew.kickoff()

    return jsonify(\\\\{'result': result\\\\})

if __name__ == '__main__':
    app.run(debug=True)
```### Celery 백그라운드 작업
```python
from celery import Celery
from crewai import Crew, Agent, Task

app = Celery('crewai_tasks')

@app.task
def execute_crew_task(topic, agents_config, tasks_config):
    # Reconstruct agents and tasks from config
    agents = [create_agent_from_config(config) for config in agents_config]
    tasks = [create_task_from_config(config) for config in tasks_config]

    # Execute crew
    crew = Crew(agents=agents, tasks=tasks)
    result = crew.kickoff(inputs=\\\\{'topic': topic\\\\})

    return result

# Usage
result = execute_crew_task.delay(
    topic="AI in Healthcare",
    agents_config=[researcher_config, analyst_config],
    tasks_config=[research_config, analysis_config]
)
```### 데이터베이스 통합
```python
from sqlalchemy import create_engine, Column, Integer, String, Text, DateTime
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
from crewai import Crew, Agent, Task
import datetime

Base = declarative_base()

class CrewExecution(Base):
    __tablename__ = 'crew_executions'

    id = Column(Integer, primary_key=True)
    crew_name = Column(String(100))
    input_data = Column(Text)
    output_data = Column(Text)
    execution_time = Column(DateTime, default=datetime.datetime.utcnow)
    status = Column(String(50))

# Database-integrated crew
class DatabaseCrew(Crew):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.engine = create_engine('sqlite:///crew_executions.db')
        Base.metadata.create_all(self.engine)
        Session = sessionmaker(bind=self.engine)
        self.session = Session()

    def kickoff(self, inputs=None):
        # Log execution start
        execution = CrewExecution(
            crew_name=self.__class__.__name__,
            input_data=str(inputs),
            status='running'
        )
        self.session.add(execution)
        self.session.commit()

        try:
            result = super().kickoff(inputs)
            execution.output_data = str(result)
            execution.status = 'completed'
        except Exception as e:
            execution.status = f'failed: \\\\{str(e)\\\\}'
            raise
        finally:
            self.session.commit()

        return result
```## 모범 사례

### 에이전트 설계 원칙
- **단일 책임**: 각 에이전트는 명확하고 집중된 역할을 가져야 함
- **명확한 목표**: 각 에이전트에 대해 구체적이고 측정 가능한 목표 정의
- **풍부한 배경 이야기**: 에이전트 동작 개선을 위해 자세한 컨텍스트 제공
- **적절한 도구**: 해당 역할에 적합한 도구로 에이전트 장비
- **위임 전략**: 복잡성을 피하기 위해 신중하게 위임 사용

### 작업 조직
- **명확한 설명**: 자세하고 모호하지 않은 작업 설명 작성
- **예상 출력**: 정확히 어떤 출력 형식이 예상되는지 명시
- **컨텍스트 종속성**: 작업 종속성 및 컨텍스트 공유를 명확히 정의
- **오류 처리**: 강력한 오류 처리 및 복구 메커니즘 구현
- **성능 모니터링**: 작업 실행 및 성능 지표 추적

### 크루 오케스트레이션
- **프로세스 선택**: 적절한 프로세스 유형 선택 (순차, 계층적, 병렬)
- **메모리 관리**: 컨텍스트 유지를 위해 전략적으로 메모리 사용
- **리소스 제한**: 실행 시간 및 반복 횟수에 대한 적절한 제한 설정
- **모니터링**: 포괄적인 로깅 및 모니터링 구현
- **테스트**: 다양한 입력으로 크루 동작 철저히 테스트

### 성능 최적화
- **에이전트 특화**: 특정 도메인에 특화된 에이전트 생성
- **도구 최적화**: 효율적인 도구 사용 및 외부 API 호출 최소화
- **캐싱**: 자주 액세스되는 데이터에 대한 캐싱 구현
- **병렬 실행**: 적절한 경우 병렬 처리 활용
- **리소스 관리**: 계산 리소스 모니터링 및 관리

## 문제 해결

### 일반적인 문제

#### 에이전트 응답 없음
```python
# Debug agent configuration
agent = Agent(
    role='Debug Agent',
    goal='Test agent responsiveness',
    backstory='Agent for debugging purposes',
    verbose=True,  # Enable verbose output
    max_iter=1,    # Limit iterations for testing
    allow_delegation=False
)

# Test with simple task
test_task = Task(
    description="Say hello and confirm you are working",
    agent=agent,
    expected_output="Simple greeting message"
)

메모리 문제

# Clear memory if needed
crew.memory.clear()

# Check memory usage
print(f"Memory entities: \\\\{len(crew.memory.entities)\\\\}")
print(f"Memory size: \\\\{crew.memory.get_memory_size()\\\\}")

도구 통합 문제

# Test tool functionality
tool = SerperDevTool()
try:
    result = tool._run("test query")
    print(f"Tool working: \\\\{result\\\\}")
except Exception as e:
    print(f"Tool error: \\\\{e\\\\}")

성능 문제

# Monitor execution time
import time

start_time = time.time()
result = crew.kickoff()
execution_time = time.time() - start_time
print(f"Execution time: \\\\{execution_time\\\\} seconds")

# Profile memory usage
import tracemalloc

tracemalloc.start()
result = crew.kickoff()
current, peak = tracemalloc.get_traced_memory()
print(f"Current memory usage: \\\\{current / 1024 / 1024:.2f\\\\} MB")
print(f"Peak memory usage: \\\\{peak / 1024 / 1024:.2f\\\\} MB")

이 포괄적인 CrewAI 치트 시트는 정교한 다중 에이전트 AI 시스템을 구축하는 데 필요한 모든 것을 제공합니다. 기본 설정부터 고급 오케스트레이션 패턴까지, 이러한 예시와 모범 사례를 사용하여 여러 전문화된 에이전트의 협업 능력을 활용하는 강력한 AI 애플리케이션을 만들 수 있습니다.

Note: Texts 15-18 were left blank in the original input, so I’ve left them blank in the translation as well.