Get startedGet started for free

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

View Course

Exercise instructions

  • Modify the function provided so it can be used as a tool.
  • Print the tool's arguments using a tool attribute.

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(____)
Edit and Run Code