DALL-E 이미지 생성
DALL-E 이미지 생성 (Image Generation with DALL-E)
CrewAI는 OpenAI의 DALL-E 통합을 지원해서, 에이전트가 태스크의 일부로 이미지를 생성할 수 있어요. 이 가이드에서는 CrewAI 프로젝트에서 DALL-E 툴을 설정하고 사용하는 방법을 차근차근 알려드릴게요.
출처: 문서
본문
Prerequisites (사전 준비)
- crewAI 설치 (최신 버전)
- DALL-E에 접근 권한이 있는 OpenAI API key
Setting Up the DALL-E Tool (DALL-E 툴 설정)
- DALL-E 툴을 임포트해요.
from crewai_tools import DallETool
- 에이전트 설정에 DALL-E 툴을 추가해요.
@agent
def researcher(self) -> Agent:
return Agent(
config=self.agents_config['researcher'],
tools=[SerperDevTool(), DallETool()], # Add DallETool to the list of tools
allow_delegation=False,
verbose=True
)
Using the DALL-E Tool (DALL-E 툴 사용하기)
에이전트에 DALL-E 툴을 추가하면, 텍스트 프롬프트를 기반으로 이미지를 생성할 수 있어요. 툴은 생성된 이미지의 URL을 반환하고, 이 URL은 에이전트의 출력에 사용되거나 이후 처리를 위해 다른 에이전트에게 전달될 수 있어요.
Example Agent Configuration (예시 에이전트 설정)
role: >
LinkedIn Profile Senior Data Researcher
goal: >
Uncover detailed LinkedIn profiles based on provided name {name} and domain {domain}
Generate a Dall-e image based on domain {domain}
backstory: >
You're a seasoned researcher with a knack for uncovering the most relevant LinkedIn profiles.
Known for your ability to navigate LinkedIn efficiently, you excel at gathering and presenting
professional information clearly and concisely.
Expected Output (기대 출력)
DALL-E 툴을 가진 에이전트는 이미지를 생성하고 응답에 URL을 제공할 수 있어요. 그러면 그 이미지를 다운로드하면 돼요.
Best Practices (모범 사례)
- 이미지 생성 프롬프트는 최상의 결과를 위해 구체적으로 작성하세요.
- 생성 시간을 고려하세요. 이미지 생성은 시간이 걸릴 수 있으니 태스크 계획에 반영하세요.
- 사용 정책을 준수하세요. 이미지를 생성할 때 항상 OpenAI의 사용 정책을 지켜야 해요.
Troubleshooting (문제 해결)
- API 접근 확인 — OpenAI API key가 DALL-E에 접근 권한이 있는지 확인하세요.
- 버전 호환성 — crewAI와 crewai-tools의 최신 버전을 사용하고 있는지 확인하세요.
- 툴 설정 — DALL-E 툴이 에이전트의 툴 목록에 올바르게 추가되었는지 확인하세요.