Creating custom tools
Now that you have a function for extracting customer data from the customers DataFrame, it's time to convert this function into a tool that's compatible with LangChain agents.
This exercise is part of the course
Developing LLM Applications with LangChain
Exercise instructions
- Add the
@tooldecorator before the function definition to convert it into a LangChain tool. - Print the tool's arguments using the
.argsattribute on the tool (e.g.,tool_name.args).
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Convert the retrieve_customer_info function into a tool
____
def retrieve_customer_info(name: str) -> str:
"""Retrieve customer information based on their name."""
customer_info = customers[customers['name'] == name]
return customer_info.to_string()
# Print the tool's arguments
print(retrieve_customer_info.____)