Bird
0
0

You want to build a Langchain tool that retrieves live stock prices for a given ticker symbol and integrate it with an agent. Which approach correctly implements this?

hard📝 Application Q8 of 15
LangChain - Agents
You want to build a Langchain tool that retrieves live stock prices for a given ticker symbol and integrate it with an agent. Which approach correctly implements this?
AWrite a function that returns random numbers, create a Tool without description, and use it in the agent
BCreate a Tool with a hardcoded stock price value and assign it to the agent without a description
CDefine a function that calls a stock price API, create a Tool with this function and description, then add it to the agent's tool list
DDirectly embed API calls inside the agent without using a Tool
Step-by-Step Solution
Solution:
  1. Step 1: Understand tool creation

    Tools should wrap functions that perform the desired task, here calling a stock price API.
  2. Step 2: Importance of description

    Providing a description helps the agent understand the tool's purpose.
  3. Step 3: Integration with agent

    The tool must be added to the agent's tool list for usage.
  4. Step 4: Eliminate incorrect options

    Hardcoded or random values do not provide live data; embedding API calls directly bypasses tool abstraction.
  5. Final Answer:

    Define a function that calls a stock price API, create a Tool with this function and description, then add it to the agent's tool list -> Option C
  6. Quick Check:

    Wrap API calls in tools with descriptions for agents [OK]
Quick Trick: Wrap API calls in tools with descriptions for agents [OK]
Common Mistakes:
MISTAKES
  • Using hardcoded or random data instead of live API calls
  • Skipping tool descriptions
  • Not adding tools to the agent's tool list

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes