Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a simple conversational agent that replies with a greeting.
Agentic AI
agent = AutoGenAgent(name='ChatBot') response = agent.[1]('Hello!')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'respond' instead of 'reply' causes an AttributeError.
Using 'send' or 'talk' are not valid methods for this agent.
✗ Incorrect
The method to get a reply from the agent is 'reply'.
2fill in blank
mediumComplete the code to initialize the agent with a system message that sets its role.
Agentic AI
agent = AutoGenAgent(name='HelperBot', system_message=[1])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using greetings or farewells as system messages confuses the agent's role.
Using vague descriptions does not set a clear role.
✗ Incorrect
The system message defines the agent's role; a helpful assistant is the correct role here.
3fill in blank
hardFix the error in the code to correctly generate a conversation turn with the agent.
Agentic AI
conversation = Conversation() conversation.add_user_message('Hi') response = conversation.[1]()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'get_reply' causes an AttributeError.
Using 'send_message' or 'start_conversation' are incorrect method calls.
✗ Incorrect
The method to generate the agent's reply in the conversation is 'generate_response'.
4fill in blank
hardFill both blanks to create a dictionary comprehension that maps user messages to their lengths if length is greater than 5.
Agentic AI
lengths = {msg: [1] for msg in messages if len(msg) [2] 5} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'msg' as value instead of 'len(msg)' gives the message text, not length.
Using '<' instead of '>' filters the wrong messages.
✗ Incorrect
We want the length of each message as the value, and filter messages longer than 5 characters.
5fill in blank
hardFill all three blanks to create a filtered dictionary of agent replies longer than 10 characters.
Agentic AI
filtered_replies = [1]: [2] for [3], reply in replies.items() if len(reply) > 10}
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'agent' as key or variable name causes confusion.
Mixing up keys and values in the comprehension.
✗ Incorrect
The dictionary keys are users, values are replies, iterating over user, reply pairs.