ImageGeneration
1. Utilizes a TextAnalyzerAgent to analyze incoming messages to identify requests for image generation and extract relevant details.
2. Leverages the provided ImageGenerator (e.g., DalleImageGenerator) to create the image.
3. Optionally caches generated images for faster retrieval in future conversations.
NOTE: This capability increases the token usage of the agent, as it uses TextAnalyzerAgent to analyze every message received by the agent.
Example:
```python import autogen from autogen.agentchat.contrib.capabilities.image_generation import ImageGeneration
Assuming you have llm configs configured for the LLMs you want to use and Dalle.
# Create the agent
agent = autogen.ConversableAgent(
name=“dalle”, llm_config={…}, max_consecutive_auto_reply=3, human_input_mode=“NEVER”
)
Create an ImageGenerator with desired settings
dalle_gen = generate_images.DalleImageGenerator(llm_config={…})Add the ImageGeneration capability to the agent
agent.add_capability(ImageGeneration(image_generator=dalle_gen))This function performs the following modifications to the agent:
1. Registers a reply function: A new reply function is registered with the agent to handle messages that potentially request image generation. This function analyzes the message and triggers image generation if necessary.
2. Creates an Agent (TextAnalyzerAgent): This is used to analyze messages for image generation requirements.
3. Updates System Message: The agent’s system message is updated to include a message indicating the capability to generate images has been added.
4. Updates Description: The agent’s description is updated to reflect the addition of the Image Generation capability. This might be helpful in certain use cases, like group chats.
Parameters: