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:
Step 1: Understand tool creation
Tools should wrap functions that perform the desired task, here calling a stock price API.
Step 2: Importance of description
Providing a description helps the agent understand the tool's purpose.
Step 3: Integration with agent
The tool must be added to the agent's tool list for usage.
Step 4: Eliminate incorrect options
Hardcoded or random values do not provide live data; embedding API calls directly bypasses tool abstraction.
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
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
Master "Agents" in LangChain
9 interactive learning modes - each teaches the same concept differently