Bird
0
0

You want to create a tool that converts temperatures from Celsius to Fahrenheit for an agent. Which code correctly creates this tool with a clear description?

hard📝 Application Q15 of 15
LangChain - Agents
You want to create a tool that converts temperatures from Celsius to Fahrenheit for an agent. Which code correctly creates this tool with a clear description?
Adef convert_temp(f): return (f - 32) * 5/9 from langchain.agents import Tool tool = Tool(name='temp_convert', func=convert_temp, description='Converts Fahrenheit to Celsius')
Bdef c_to_f(c): return c + 32 from langchain.agents import Tool temp_tool = Tool(name='temp', func=c_to_f, description='Temperature conversion')
Cdef c_to_f(c): return (c * 9/5) + 32 from langchain.agents import Tool temp_tool = Tool(name='temp_convert', func=c_to_f, description='Converts Celsius to Fahrenheit')
Ddef c_to_f(c): return (c * 9/5) + 32 tool = Tool(func=c_to_f, description='Convert temp')
Step-by-Step Solution
Solution:
  1. Step 1: Verify function correctness

    The c_to_f(c) function returns (c * 9/5) + 32, which correctly converts Celsius to Fahrenheit using the standard formula.
  2. Step 2: Check tool creation parameters

    Tool(name='temp_convert', func=c_to_f, description='Converts Celsius to Fahrenheit') uses name, func, and a clear description matching the task.
  3. Final Answer:

    def c_to_f(c):\n return (c * 9/5) + 32\n\nfrom langchain.agents import Tool\n\ntemp_tool = Tool(name='temp_convert', func=c_to_f, description='Converts Celsius to Fahrenheit') -> Option C
  4. Quick Check:

    Correct formula and clear tool setup = A [OK]
Quick Trick: Use correct formula and full tool parameters [OK]
Common Mistakes:
MISTAKES
  • Using wrong temperature formula
  • Omitting tool name or description
  • Confusing Celsius to Fahrenheit with reverse

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes