Reflection
Reflection and Blog post WritingΒΆ
In this example, we will setup up a workflow for reviewing and improving blog posts using nested chats. The workflow includes roles for a writer, critic, and various reviewers (SEO, Legal, Ethics, and Meta).
Agent RolesΒΆ
- Writer: Writes blog posts based on given topics.
- Critic: Asks for reviews and provides feedback on the writer's work.
- SEO Reviewer: Optimizes content for search engines.
- Legal Reviewer: Ensures content is legally compliant.
- Ethics Reviewer: Ensures content is ethically sound.
- Meta Reviewer: Aggregates feedback from other reviewers.
Models UsedΒΆ
Feel free to use any models that suit your requirements. Here are the models used in this example:
- SEO Reviewer:
gpt-3.5-turbo
- Legal Reviewer:
gpt-3.5-turbo
- Ethics Reviewer:
gpt-3.5-turbo
- Meta Reviewer:
gpt-3.5-turbo
- Writer:
gpt-3.5-turbo
- Critic:
gpt-3.5-turbo
Setup the AgentsΒΆ
SEO ReviewerΒΆ
- Add an agent named SEO reviewer.
In the System Message, set:
Link the agent to a model.
Legal ReviewerΒΆ
- Add an agent named Legal reviewer.
In the System Message, set:
Link the agent to a model.
Ethics ReviewerΒΆ
- Add an agent named Ethics reviewer.
In the System Message, set:
Link the agent to a model.
Meta ReviewerΒΆ
- Add an agent named Meta reviewer.
In the System Message, set:
Link the agent to a model.
Writer AgentΒΆ
- Add a new agent named Writer.
In the System Message, set:
Link the agent to a model.
Critic AgentΒΆ
- Add a new agent named Critic.
In the System Message, set:
Link the agent to a model.
Note
We will come back to the Critic agent to configure nested chats after setting up the agent connections.
Agent ConnectionsΒΆ
Writer => CriticΒΆ
- Connect the Critic agent to the Writer agent.
- On the message tab, set the type to "Text" and the content to:
Nested chatsΒΆ
For the rest of the connections, we will set up nested chats to gather feedback from the SEO, Legal, Ethics, and Meta reviewers. Add a link from the Critic agent to each of the reviewers, and set the chat type to "Nested Chat". Set Max turns to 1 and Summary method to "Last Message". For the nested chat content, we will use a custom method to send the content to the SEO, Legal, and Ethics reviewers:
def nested_chat_message(recipient, messages, sender, config):
"""Ask for a review."""
return f"""Review the following content.
\n\n {recipient.chat_messages_for_summary(sender)[-1]['content']}"""
For the Meta reviewer, we use the "Text" type:
Nested chat registrationΒΆ
- Go to the Critic agentβs settings and navigate to the Nested Chats tab.
- The nested chat is triggered when the writer replies to the critic's message with the content to be reviewed, so on the "Triggered by" select the Writer agent and check the "Agent's reply" box.
- Set up the messages to be sent when the chat is triggered:
- Critic => SEO reviewer
- Critic => Legal reviewer
- Critic => Ethics reviewer
- Critic => Meta reviewer
4. Workflow Flow OrderΒΆ
- Open the Edit Flow menu.
- Name the flow as Reflection or another suitable name.
- Set the initial flow order to start with Critic => Writer.
5. Run the flowΒΆ
We are ready to run the flow. Hit the play button to start the flow. The critic will ask the writer to write a blog post about DeepLearning.AI. The writer will then write the blog post and send it to the critic for review. The critic will then send the content to the SEO, Legal, Ethics, and Meta reviewers for feedback. You can check the logs to see the flow of the conversation.
Files used in this example:
- Flow: Reflection.waldiez