IniziaInizia gratis

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.

Questo esercizio fa parte del corso

Developing LLM Applications with LangChain

Visualizza il corso

Istruzioni dell'esercizio

  • Add the @tool decorator before the function definition to convert it into a LangChain tool.
  • Print the tool's arguments using the .args attribute on the tool (e.g., tool_name.args).

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

# 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.____)
Modifica ed esegui il codice