search
HomeTechnology peripheralsAITool Calling in LLMs

Tool Calling in LLMs

Apr 14, 2025 am 11:28 AM

Large language models (LLMs) have surged in popularity, with the tool-calling feature dramatically expanding their capabilities beyond simple text generation. Now, LLMs can handle complex automation tasks such as dynamic UI creation and autonomous actions. Trained on massive datasets, these models excel at understanding and producing structured data, making them ideal for precise tool-calling applications. This has fueled their widespread adoption in AI-driven software development, where tool-calling – from basic functions to sophisticated agents – is now central. This article explores the fundamentals of LLM tool calling and demonstrates how to implement it using open-source tools to build powerful agents.

Key Learning Objectives

  • Grasp the concept of LLM tools.
  • Understand the fundamentals of tool calling and its applications.
  • Explore tool-calling implementations in OpenAI (ChatCompletions API, Assistants API, parallel tool calling, and structured output), Anthropic models, and LangChain.
  • Learn to construct effective AI agents using open-source resources.

*This article is part of the***Data Science Blogathon.

Table of Contents

  • What are Tools?
  • What is Tool Calling?
  • How Does Tool Calling Work?
    • Example Use Cases
  • Tool Calling with OpenAI Models
    • Utilizing the Assistant API
    • Parallel Function Calling
    • Structured Output
  • Tool Calling with Anthropic Claude
  • Tool Calling with LangChain
    • Schema Definition with Pydantic
  • Building Agents with Tool Calling
  • Introducing Composio
  • Building a GitHub Agent
  • Frequently Asked Questions

What are Tools?

Tools are mechanisms allowing LLMs to interact with external systems. These tools are functions accessible to the LLM, executed independently when the LLM deems their use necessary. A typical tool definition includes:

  • Name: A descriptive function/tool name.
  • Description: A detailed tool explanation.
  • Parameters: A JSON schema defining the function/tool parameters.

What is Tool Calling?

Tool calling enables the model to generate responses matching a user-defined function schema. When the LLM decides a tool is needed, it produces a structured output conforming to the tool's argument schema. For example, given a get_weather function schema, a query about a city's weather would return a formatted schema of function arguments, enabling execution to retrieve the weather data. Importantly, the LLM doesn't execute the tool; it generates the structured input for external execution.

How Does Tool Calling Work?

Companies like OpenAI and Anthropic have trained models to select appropriate tools based on context. Each provider handles tool invocation and responses differently. Generally:

  1. Define Tools and Provide a Prompt: Define tools with names, descriptions, and structured schemas, along with the user's prompt (e.g., "What's the weather in London?").
  2. LLM Tool Selection: The LLM assesses tool necessity. If so, it halts text generation and generates a JSON-formatted response with tool parameter values.
  3. Extract, Execute, and Return: Extract parameters, run the function, and return outputs to the LLM.
  4. Answer Generation: The LLM uses tool outputs to formulate the final answer.

Tool Calling in LLMs

Example Use Cases

  • Action Enablement: Connect LLMs to applications (Gmail, GitHub, Discord) to automate actions (sending emails, creating pull requests, sending messages).
  • Data Provision: Fetch data from knowledge bases (web, Wikipedia, APIs) to provide specific information to LLMs.
  • Dynamic UIs: Update application UIs based on user input.

The following sections detail tool-calling approaches in OpenAI, Anthropic, and LangChain. Open-source models (like Llama 3) and inference providers (like Groq) also support tool calling.

(The remainder of the article would continue with detailed explanations of tool calling in OpenAI, Anthropic, LangChain, building agents, Composio, and a GitHub agent example, mirroring the structure and content of the original input but with rephrased sentences and vocabulary.)

The above is the detailed content of Tool Calling in LLMs. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Tool Calling in LLMsTool Calling in LLMsApr 14, 2025 am 11:28 AM

Large language models (LLMs) have surged in popularity, with the tool-calling feature dramatically expanding their capabilities beyond simple text generation. Now, LLMs can handle complex automation tasks such as dynamic UI creation and autonomous a

How ADHD Games, Health Tools & AI Chatbots Are Transforming Global HealthHow ADHD Games, Health Tools & AI Chatbots Are Transforming Global HealthApr 14, 2025 am 11:27 AM

Can a video game ease anxiety, build focus, or support a child with ADHD? As healthcare challenges surge globally — especially among youth — innovators are turning to an unlikely tool: video games. Now one of the world’s largest entertainment indus

UN Input On AI: Winners, Losers, And OpportunitiesUN Input On AI: Winners, Losers, And OpportunitiesApr 14, 2025 am 11:25 AM

“History has shown that while technological progress drives economic growth, it does not on its own ensure equitable income distribution or promote inclusive human development,” writes Rebeca Grynspan, Secretary-General of UNCTAD, in the preamble.

Learning Negotiation Skills Via Generative AILearning Negotiation Skills Via Generative AIApr 14, 2025 am 11:23 AM

Easy-peasy, use generative AI as your negotiation tutor and sparring partner. Let’s talk about it. This analysis of an innovative AI breakthrough is part of my ongoing Forbes column coverage on the latest in AI, including identifying and explaining

TED Reveals From OpenAI, Google, Meta Heads To Court, Selfie With MyselfTED Reveals From OpenAI, Google, Meta Heads To Court, Selfie With MyselfApr 14, 2025 am 11:22 AM

The ​TED2025 Conference, held in Vancouver, wrapped its 36th edition yesterday, April 11. It featured 80 speakers from more than 60 countries, including Sam Altman, Eric Schmidt, and Palmer Luckey. TED’s theme, “humanity reimagined,” was tailor made

Joseph Stiglitz Warns Of The Looming Inequality Amid AI Monopoly PowerJoseph Stiglitz Warns Of The Looming Inequality Amid AI Monopoly PowerApr 14, 2025 am 11:21 AM

Joseph Stiglitz is renowned economist and recipient of the Nobel Prize in Economics in 2001. Stiglitz posits that AI can worsen existing inequalities and consolidated power in the hands of a few dominant corporations, ultimately undermining economic

What is Graph Database?What is Graph Database?Apr 14, 2025 am 11:19 AM

Graph Databases: Revolutionizing Data Management Through Relationships As data expands and its characteristics evolve across various fields, graph databases are emerging as transformative solutions for managing interconnected data. Unlike traditional

LLM Routing: Strategies, Techniques, and Python ImplementationLLM Routing: Strategies, Techniques, and Python ImplementationApr 14, 2025 am 11:14 AM

Large Language Model (LLM) Routing: Optimizing Performance Through Intelligent Task Distribution The rapidly evolving landscape of LLMs presents a diverse range of models, each with unique strengths and weaknesses. Some excel at creative content gen

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment