Skip to content

Commit 32a4076

Browse files
committed
Revise User Guide to reflect new tool calling update
1 parent b11d17d commit 32a4076

File tree

3 files changed

+40
-33
lines changed

3 files changed

+40
-33
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ void loop() {
147147
}
148148
```
149149
150-
## Tool Calls Support
151-
Tool calls (function calling) enable the AI model to request specific actions from your ESP32 application. This feature allows:
150+
## Tool Calls (Tool Calling) Support
151+
Tool calls (a.k.a. talling calling) enable the AI model to request specific actions from your ESP32 application. This feature allows:
152152
153153
- Two-way interaction : AI can request data or actions from your device
154154
- Structured data exchange : Receive properly formatted JSON for easy parsing

doc/User Guides/3 Tool Calls Implementation Basics.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# ESP32_AI_Connect Library User Guide - 3 Tool Calls Implementation Basics
2-
> **Version 0.0.2** • Revised: May 09, 2025 • Author: AvantMaker • [https://www.AvantMaker.com](https://www.AvantMaker.com)
2+
> **Version 0.0.5** • Revised: May 12, 2025 • Author: AvantMaker • [https://www.AvantMaker.com](https://www.AvantMaker.com)
33
## Overview
44

5-
This guide will walk you through the process of setting up and using tool calls (function calling) with Large Language Models (LLMs) using the ESP32_AI_Connect library. We'll use the `tool_calls_demo.ino` sketch stored in the examples folder as our reference implementation, explaining each component in detail so you can understand how to integrate AI function calling capabilities into your ESP32 projects.
5+
This guide will walk you through the process of setting up and using tool calls (tool calling) with Large Language Models (LLMs) using the ESP32_AI_Connect library. We'll use the `tool_calling_demo.ino` sketch stored in the examples folder as our reference implementation, explaining each component in detail so you can understand how to integrate AI tool calling capabilities into your ESP32 projects with ESP32_AI_Connect.
66

77
## Prerequisites
88

@@ -12,7 +12,7 @@ Before you begin, make sure you have:
1212
- Arduino IDE installed with ESP32 board support
1313
- ESP32_AI_Connect library installed
1414
- WiFi connectivity
15-
- An API key for your chosen AI platform (OpenAI is recommended for tool calls)
15+
- An API key for your chosen AI platform (Ensure the AI Model you choose supports Tool Calls functionality)
1616
- Basic understanding of JSON and Arduino programming
1717

1818
## Step 1: Enable Tool Calls in Configuration
@@ -21,7 +21,7 @@ First, ensure that tool calls support is enabled in the library configuration fi
2121

2222
```cpp
2323
// --- Tool Calls Support ---
24-
// Uncomment the following line to enable tool calls (function calling) support
24+
// Uncomment the following line to enable tool calls (tool calling) support
2525
// This will add tcToolSetup and tcChat methods to the library
2626
// If you don't need tool calls, keep this commented out to save memory
2727
#define ENABLE_TOOL_CALLS
@@ -60,7 +60,7 @@ ESP32_AI_Connect aiClient(platform, apiKey, model);
6060
```
6161
6262
This line initializes the AI client with parameters:
63-
- The platform identifier (typically `"openai"` for tool calls)
63+
- The platform identifier ("openai", "gemini", "claude" or "deepseek", etc.)
6464
- Your API key
6565
- The model name (e.g., `"gpt-3.5-turbo"` or `"gpt-4"`)
6666
- Optional custom endpoint (if you're using a custom API endpoint)
@@ -93,7 +93,7 @@ void setup() {
9393

9494
## Step 5: Define Your Tools
9595

96-
Tool calls require defining the functions that the AI can call. Each tool is defined as a JSON object that specifies the function name, description, and parameters:
96+
Tool calls require defining the tool(s) that the AI can call. Each tool is defined as a JSON object that specifies the function name, description, and parameters:
9797

9898
```cpp
9999
// --- Define Tools for Tool Calling ---
@@ -158,7 +158,7 @@ These optional methods allow you to:
158158

159159
Each setter also has a corresponding getter method to retrieve the current value.
160160

161-
Different AI platforms support different `toolChoice` parameters. The table below shows the allowed values for each platform:
161+
Different AI platforms support different `tool_choice` parameters. The table below shows the allowed values for each platform:
162162

163163
| Tool Choice Mode | OpenAI API | Gemini API | Anthropic Claude API |
164164
|------------------|------------|------------|----------------------|
@@ -171,13 +171,13 @@ Different AI platforms support different `toolChoice` parameters. The table belo
171171
Notes on tool choice options:
172172
- `"auto"`: Let the AI decide whether to use tools (default behavior)
173173
- `"none"`: Don't use tools
174-
- `"required"`: (OpenAI only) Forces the model to use a tool
175-
- `"any"`: (Gemini and Claude only) Model should use a tool if relevant
174+
- `"required"`: (OpenAI and OpenAI Compatible) Forces the model to use a tool
175+
- `"any"`: (Gemini and Claude) Model should use a tool if relevant
176176
- Tool Choice JSON: Specifies a particular tool to use (format varies by platform)
177177

178178
## Step 8: Send a Message to Trigger Tool Calls
179179

180-
Now we can send a message that will likely trigger a tool call:
180+
Now we can send a message that may trigger a tool call based on user prompt content:
181181

182182
```cpp
183183
// --- Perform Tool Calling Chat ---

doc/User Guides/4 Tool Calls Follow-Up Techniques.md

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# ESP32_AI_Connect Library User Guide - 4 Tool Calls Follow-Up Techniques
2-
> **Version 0.0.2** • Revised: May 09, 2025 • Author: AvantMaker • [https://www.AvantMaker.com](https://www.AvantMaker.com)
2+
> **Version 0.0.3** • Revised: May 12, 2025 • Author: AvantMaker • [https://www.AvantMaker.com](https://www.AvantMaker.com)
33
## Introduction
44

55
This article is a follow-up to the previous guide "Tool Calls Implementation Basics". If you haven't read that article yet, please do so before continuing, as this guide builds upon the concepts introduced there.
@@ -94,12 +94,6 @@ String getWeatherData(const String& city, const String& units) {
9494
}
9595
```
9696
97-
The tool results must be formatted as a JSON array of objects, where each object contains:
98-
- `tool_call_id`: The ID of the tool call (provided by the AI in the original tool call)
99-
- `function`: An object containing:
100-
- `name`: The name of the function that was called
101-
- `output`: The result of the function execution (as a string)
102-
10397
## Step 2: Parsing Tool Calls and Executing Functions
10498
10599
When you receive a response with tool calls, you need to parse the JSON and execute the appropriate functions:
@@ -167,15 +161,22 @@ String toolResultsJson;
167161
serializeJson(toolResults, toolResultsJson);
168162
```
169163

164+
165+
The tool results must be formatted as a JSON array of objects, where each object contains:
166+
- `tool_call_id`: The ID of the tool call (provided by the AI in the original tool call)
167+
- `function`: An object containing:
168+
- `name`: The name of the function that was called
169+
- `output`: The result of the function execution (as a string)
170+
170171
## Step 3: Sending the Tool Results Back to the AI
171172

172173
Before sending the results back to the AI, you can configure the follow-up request with separate parameters:
173174

174175
```cpp
175-
// Additional follow-up configuration
176+
// Additional follow-up optional configuration
176177
// These only affect the follow-up request, not the initial tool call
177-
aiClient.setTCReplyMaxTokens(350); // Maximum tokens for the follow-up response
178-
aiClient.setTCReplyToolChoice("auto"); // Tool choice for the follow-up (can be different from initial)
178+
aiClient.setTCReplyMaxTokens(350); // (Optional) Maximum tokens for the follow-up response
179+
aiClient.setTCReplyToolChoice("auto"); // (Optional) Tool choice for the follow-up (can be different from initial)
179180

180181
// You can also use a JSON string to specify a particular tool
181182
// aiClient.setTCReplyToolChoice(R"({"type": "function","function": {"name": "control_device"}})");
@@ -226,11 +227,22 @@ else {
226227
}
227228
```
228229

229-
Note that different AI platforms use different terminology for finish reasons:
230+
Note that different AI platforms use different terminology for folow-up tool calling finish reasons:
230231
- OpenAI and Gemini use "tool_calls"
231-
- Anthropic Claude uses "tool_use"
232-
- OpenAI and Gemini use "stop" for completed responses
233-
- Anthropic Claude uses "end_turn" for completed responses
232+
233+
This indicates the AI is requesting for more tool calling to complete user's requests.
234+
235+
- OpenAI and Gemini use "stop"
236+
237+
This indicates the AI has completed user's follow-up tool calling requests.
238+
239+
- Anthropic Claude uses "tool_use"
240+
241+
This indicates the AI is requesting for more tool calling to complete user's requests.
242+
243+
- Anthropic Claude uses "end_turn"
244+
245+
This indicates the AI has completed user's follow-up tool calling requests.
234246

235247
## Resetting Tool Call Configuration
236248

@@ -266,7 +278,7 @@ Let's walk through the complete flow of a tool call interaction using the exampl
266278
while(1) { delay(1000); } // Halt on failure
267279
}
268280

269-
// Configure tool calling parameters
281+
// Configure optional tool calling parameters
270282
aiClient.setTCChatSystemRole("You are a smart home assistant.");
271283
aiClient.setTCChatMaxTokens(300);
272284
aiClient.setTCChatToolChoice("auto");
@@ -293,7 +305,7 @@ Let's walk through the complete flow of a tool call interaction using the exampl
293305
// ... (code from Step 2 above) ...
294306
```
295307

296-
5. **Configure Follow-Up Request**: Set parameters for the follow-up request
308+
5. **Configure Follow-Up Request(Optional)**: Set parameters for the follow-up request
297309
```cpp
298310
aiClient.setTCReplyMaxTokens(350);
299311
aiClient.setTCReplyToolChoice("auto");
@@ -310,11 +322,6 @@ Let's walk through the complete flow of a tool call interaction using the exampl
310322
// ... (code from Step 4 above) ...
311323
```
312324

313-
8. **Reset Configuration**: Clear all tool call settings
314-
```cpp
315-
aiClient.tcChatReset();
316-
```
317-
318325
## Key Considerations for Tool Call Follow-Up
319326

320327
### 1. Memory Management

0 commit comments

Comments
 (0)