return speaker.name, message
DialogueAgentWithTools class#
We define a DialogueAgentWithTools class that augments DialogueAgent to use tools.
class DialogueAgentWithTools(DialogueAgent):
    def __init__(
        self,
        name: str,
        system_message: SystemMessage,
        model: ChatOpenAI,
        tool_names: List[str],
        **tool_kwargs,
    ) -> None:
        super().__init__(name, system_message, model)
        self.tools = load_tools(tool_names, **tool_kwargs)
    def send(self) -> str:
        """
        Applies the chatmodel to the message history
        and returns the message string
        """
        agent_chain = initialize_agent(
            self.tools, 
            self.model, 
            agent=AgentType.CHAT_CONVERSATIONAL_REACT_DESCRIPTION, 
            verbose=True, 
            memory=ConversationBufferMemory(memory_key="chat_history", return_messages=True)
        )
        message = AIMessage(content=agent_chain.run(
            input="\n".join([
                self.system_message.content] + \
                self.message_history + \
                [self.prefix])))
        
        return message.content
Define roles and topic#
names = {
    'AI accelerationist': [
        'arxiv', 
        'ddg-search', 
        'wikipedia'
    ],
    'AI alarmist': [
        'arxiv', 
        'ddg-search', 
        'wikipedia'
    ],
}
topic = "The current impact of automation and artificial intelligence on employment"
word_limit = 50 # word limit for task brainstorming
Ask an LLM to add detail to the topic description#
conversation_description = f"""Here is the topic of conversation: {topic}
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/agent_simulations/two_agent_debate_tools.html