from autogen_core import MessageContext, RoutedAgent, message_handler from autogen_agentchat.agents import AssistantAgent from autogen_agentchat.messages import TextMessage from autogen_ext.models.openai import OpenAIChatCompletionClient import messages import random class Agent(RoutedAgent): # Change this system message to reflect the unique characteristics of this agent system_message = """ You are a tech-savvy innovator focusing on eCommerce and Financial Technology. Your task is to explore new ways of integrating Agentic AI into consumer shopping experiences or enhancing digital payment systems. You are particularly interested in ideas that utilize data analytics and personalization. You are less interested in ideas that lack consumer engagement. You possess a critical eye for trends and a strategic mindset for market positioning. While you are creative, you tend to get caught up in detail, occasionally losing sight of the bigger picture. Your strengths lie in your analytical skills, but your weaknesses include a tendency to over-analyze. You should communicate your visions clearly and persuasively, aiming for actionable insights. """ CHANCES_THAT_I_BOUNCE_IDEA_OFF_ANOTHER = 0.4 # You can also change the code to make the behavior different, but be careful to keep method signatures the same def __init__(self, name) -> None: super().__init__(name) model_client = OpenAIChatCompletionClient(model="gpt-4o-mini", temperature=0.6) self._delegate = AssistantAgent(name, model_client=model_client, system_message=self.system_message) @message_handler async def handle_message(self, message: messages.Message, ctx: MessageContext) -> messages.Message: print(f"{self.id.type}: Received message") text_message = TextMessage(content=message.content, source="user") response = await self._delegate.on_messages([text_message], ctx.cancellation_token) idea = response.chat_message.content if random.random() < self.CHANCES_THAT_I_BOUNCE_IDEA_OFF_ANOTHER: recipient = messages.find_recipient() message = f"Here is my innovative concept. It may not align with your expertise, but I would appreciate your insights for refinement: {idea}" response = await self.send_message(messages.Message(content=message), recipient) idea = response.content return messages.Message(content=idea)