Bird
0
0

Given this custom agent code snippet, what will be printed?

medium📝 component behavior Q13 of 15
LangChain - Agents
Given this custom agent code snippet, what will be printed?
class MyAgent:
    def plan(self, input_text):
        if 'hello' in input_text.lower():
            return 'Greet'
        return 'Ignore'

agent = MyAgent()
print(agent.plan('Hello there!'))
AGreet
BIgnore
Chello
DError
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the plan method logic

    The method checks if 'hello' is in the input text (case-insensitive). If yes, returns 'Greet'.
  2. Step 2: Apply input to the method

    Input is 'Hello there!', which contains 'hello' ignoring case, so it returns 'Greet'.
  3. Final Answer:

    Greet -> Option A
  4. Quick Check:

    Input contains 'hello' -> returns 'Greet' [OK]
Quick Trick: Check string contains 'hello' ignoring case [OK]
Common Mistakes:
MISTAKES
  • Ignoring case sensitivity in string check
  • Expecting the method to print input text
  • Assuming method returns 'Ignore'

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes