Introduction
AutoGen helps build smart chat helpers that can talk and work together to answer questions or solve problems easily.
Jump into concepts and practice - no test required
from autogen import Assistant, User user = User(name="User") assistant = Assistant(name="Assistant") response = assistant.chat("Hello! How can I help you today?") print(response)
assistant = Assistant(name="HelperBot") response = assistant.chat("What is the weather today?") print(response)
user = User(name="Alice") assistant = Assistant(name="HelperBot") user_message = "Can you help me book a flight?" response = assistant.chat(user_message) print(response)
from autogen import Assistant, User user = User(name="User") assistant1 = Assistant(name="Helper1") assistant2 = Assistant(name="Helper2") response1 = assistant1.chat("Hello, can you help with math?") response2 = assistant2.chat(response1) print(response2)
from autogen import Assistant, User # Create user and assistant agents user = User(name="User") assistant = Assistant(name="Assistant") # User sends a greeting user_message = "Hi! Can you tell me a fun fact?" # Assistant replies assistant_response = assistant.chat(user_message) print(f"User: {user_message}") print(f"Assistant: {assistant_response}")
AutoAgent(name='AgentName') to create agents.User = AutoAgent(name='User') uses AutoAgent with the correct parameter name='User'.print(conversation.history)?
user = AutoAgent(name='User') assistant = AutoAgent(name='Assistant') conversation = AutoConversation(agents=[user, assistant]) conversation.start() conversation.step() print(conversation.history)
conversation.start() initializes the conversation, and conversation.step() runs one exchange between agents.conversation.history storesuser = AutoAgent(name='User') assistant = AutoAgent(name='Assistant') conversation = AutoConversation(agents=[user, assistant]) conversation.start() conversation.step() print(conversation.history) conversation.step()
conversation.step() advances the conversation. Calling it twice without checking if conversation ended can cause errors.