AI Hints
LangChain · Lesson 37 of 120

What Are Tools

Giving the model hands.

⏱ 2 min read▶ Video at 40:25🎓 Free
Watch this lesson in the LangChain courseWatch on YouTube ↗Full LangChain course

A model on its own can only write text. It can't check Riverside Books' stock, look up an order, or send an email. Tools change that. A tool is a function the model can ask you to run.

What Are Tools
From the video: What Are Tools
  • Models only write text
  • They can't look things up
  • Tools: functions it can request

How a tool call works

Here's the idea. You tell the model which tools exist, with a name and description for each. The user asks a question. The model decides a tool would help, and replies with a tool call, the tool's name and arguments. Your code runs the function. And the result goes back to the model, which writes the final answer.

  1. Describe tools
  2. User asks
  3. Model requests a tool
  4. Your code runs it
  5. Model answers
How a tool call works
From the video: How a tool call works

Important to understand

Two things are important. The model never runs code itself. It only asks, and your program decides whether to run the tool. And the model chooses tools based only on their names and descriptions, so writing those well matters a lot.

keyvalue
Modelonly asks
Your coderuns the tool
Choicebased on descriptions
Sowrite them well

Summary

Tools are functions the model can request. The model asks, your code runs it, and the result goes back. Next, turning a Python function into a tool.

Key takeaways
  • Model requests
  • Code runs
  • Result returns
Next up: The tool Decorator — functions become tools