Skip to content

Latest commit

 

History

History
72 lines (48 loc) · 3.35 KB

File metadata and controls

72 lines (48 loc) · 3.35 KB

TOOL CALLING

PREREQUISITES

If you intend to use a local LLM through Ollama, you will need to install Ollama and the llama3 LLM model via Ollama.

To ensure that you have successfully downloaded and installed all of the above, run the following commands through your terminal:

  • Check whether Ollama is installed: ollama --version

  • Check whether the required models are available: ollama list

  • Check out this video to learn how to install Ollama on your system.

CONCEPTS

Most Large Language Models cannot take actions on their own. They can receive text or other media as input (e.g. images, PDFs, audio, etc.) and respond, usually, in the form of natural language (either text or speech).

Tool calling provides a way to allow LLMs to decide whether they need to execute a particular function, prepare the arguments that need to be passed to that function and finally execute it to receive some output that can be used as additional information to the final text response from the LLM.

This allows LLMs to not only interact with humans, through natural language, but also interact directly with software systems such as databases, APIs and other.

By giving LLMs the ability to take action (by selecting one of the available tools and using it) we are entering the world of Agents, "systems that take a high-level task and use a Large Language Model as a reasoning engine to decide what actions to take and execute those actions".

This guide is going to help you get started with the Tool Calling capabilities that are provided by LangChain.js.

STEPS

This guide is based on version 0.3 of LangChain.js.

  • Clone the repo and install all required dependencies:

    • git clone git@github.com:in-tech-gration/LangChain.js.git
    • cd LangChain.js/tool-calling
    • npm install or npm i
  • Step 1:

    • Dependencies:
      • npm install zod @langchain/core @langchain/ollama
    • Code: basics-01.js
  • Step 2:

  • Step 3:

  • Step 4:

  • Extras (5): Querying a Database:

REFERENCES & RESOURCES

CHANGELOG

  • Create a basic step-by-step Tool Calling process
  • Create an agent that does arithmetic operations and checks for Cryptocurrency prices
  • Create an agent that can make calls to a SQLite Music database