MulaiMulai sekarang secara 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.

Latihan ini adalah bagian dari kursus

Developing LLM Applications with LangChain

Lihat Kursus

Petunjuk latihan

  • 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).

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# 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.____)
Edit dan Jalankan Kode