Bird
0
0

Consider this custom agent class:

medium📝 component behavior Q4 of 15
LangChain - Agents
Consider this custom agent class:
class CustomAgent:
    def plan(self, input_text):
        return f'Action chosen: {input_text[::-1]}'

agent = CustomAgent()

What will be the output of agent.plan('Hello')?
A'Action chosen: Hello'
B'Action chosen: HELLO'
C'Action chosen: olleH'
D'Action chosen: hello'
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the plan method

    The method returns a string with the input_text reversed using slicing input_text[::-1].
  2. Step 2: Reverse 'Hello'

    Reversing 'Hello' results in 'olleH'.
  3. Final Answer:

    'Action chosen: olleH' -> Option C
  4. Quick Check:

    Reversing string with slicing [OK]
Quick Trick: String slicing reverses input [OK]
Common Mistakes:
MISTAKES
  • Assuming the string is converted to uppercase
  • Thinking the string remains unchanged
  • Confusing reversal with lowercase conversion

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes