@aquiles-ai/ishikawa-toolkit 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -20,7 +20,7 @@ npm i @aquiles-ai/ishikawa-toolkit
20
20
  Create a file `calculator.ts`:
21
21
 
22
22
  ```typescript
23
- export default function calculator(a: number, b: number, operation: string) {
23
+ export default function calculator({a, b, operation}: {a: number; b: number; operation: string}) {
24
24
  switch(operation) {
25
25
  case 'add': return a + b;
26
26
  case 'subtract': return a - b;
@@ -82,14 +82,136 @@ console.log(tool.metadata.description);
82
82
  // Output: "Performs basic mathematical operations"
83
83
 
84
84
  // Execute the tool
85
- const result = await tool.execute(10, 5, 'add');
85
+ const result = await tool.execute({a: 10, b: 5, operation:'add'});
86
86
  console.log(result); // Output: 15
87
87
 
88
88
  // Or use shortcut
89
- const result2 = await manager.execute('calculator', 20, 4, 'divide');
89
+ const result2 = await manager.executeTool('calculator', {a: 20, b: 4, operation: 'divide'});
90
90
  console.log(result2); // Output: 5
91
91
 
92
92
  // List all registered tools
93
93
  const tools = await manager.list();
94
94
  console.log(tools); // Output: ['calculator', ...]
95
95
  ```
96
+ ## Using with Local LLMs
97
+
98
+ Ishikawa-toolkit works seamlessly with local LLM servers like vLLM. Here's how to set up function calling with a local model:
99
+
100
+ ### 1. Start vLLM Server
101
+
102
+ Start your vLLM server with tool calling enabled:
103
+ ```bash
104
+ vllm serve openai/gpt-oss-20b \
105
+ --served-model-name gpt-oss-20b \
106
+ --host 0.0.0.0 \
107
+ --port 8000 \
108
+ --async-scheduling \
109
+ --enable-auto-tool-choice \
110
+ --tool-call-parser openai \
111
+ --api-key dummyapikey
112
+ ```
113
+
114
+ ### 2. Implement the Agent Loop
115
+
116
+ Here's a complete example using the `calculator` tool from the Quick Start section:
117
+
118
+ ```typescript
119
+ import OpenAI from "openai";
120
+ import { ToolManager } from "@aquiles-ai/ishikawa-toolkit";
121
+
122
+ const client = new OpenAI({
123
+ baseURL: "http://localhost:8000/v1",
124
+ apiKey: "dummyapikey"
125
+ });
126
+
127
+ const tools = new ToolManager();
128
+ const namesTools = await tools.listTools();
129
+
130
+ const allToolsMetadata = await Promise.all(
131
+ namesTools.map(async (toolName) => {
132
+ try {
133
+ return await tools.getMetadataTool(toolName);
134
+ } catch (error) {
135
+ console.error(`X Error cargando ${toolName}:`, error);
136
+ return null;
137
+ }
138
+ })
139
+ );
140
+
141
+ const toolsMetadata = allToolsMetadata.filter(m => m !== null).map(m => ({
142
+ type: m.type,
143
+ name: m.name,
144
+ description: m.description,
145
+ parameters: m.parameters
146
+ }));
147
+
148
+ let input = [
149
+ {
150
+ role: "user",
151
+ content: "Can you validate the basic operations using the tool (The tool you need to use is the 'calculator', always use it)?"
152
+ },
153
+ ];
154
+
155
+ let response = await client.responses.create({
156
+ model: "gpt-oss-20b",
157
+ tools: toolsMetadata,
158
+ input,
159
+ });
160
+
161
+ // console.log("Response 1:", response);
162
+
163
+ for (const item of response.output) {
164
+ if (item.type == "function_call") {
165
+ const cleanName = item.name.split('<|')[0].trim();
166
+
167
+ if (namesTools.includes(cleanName)) {
168
+ console.log("Running the tool: " + cleanName);
169
+
170
+ let parsedArgs = {};
171
+ try {
172
+ parsedArgs = typeof item.arguments === "string"
173
+ ? JSON.parse(item.arguments)
174
+ : item.arguments ?? {};
175
+ } catch (e) {
176
+ console.error("X Error parsing function arguments:", e);
177
+ }
178
+
179
+ try {
180
+ const result = await tools.executeTool(cleanName, parsedArgs);
181
+ console.log(`Result: ${result}`);
182
+
183
+ input.push({
184
+ ...item,
185
+ name: cleanName
186
+ });
187
+
188
+ input.push({
189
+ type: "function_call_output",
190
+ call_id: item.call_id,
191
+ output: String(result),
192
+ });
193
+ } catch (err) {
194
+ console.error("X Tool execution error:", err);
195
+ input.push(item);
196
+ input.push({
197
+ type: "function_call_output",
198
+ call_id: item.call_id,
199
+ output: JSON.stringify({ error: String(err) }),
200
+ });
201
+ }
202
+ }
203
+ }
204
+ }
205
+
206
+ const response2 = await client.responses.create({
207
+ model: "gpt-oss-20b",
208
+ instructions: "Answer based on the results obtained from the tool. What inputs did you provide and what output did you obtain?",
209
+ tools: toolsMetadata,
210
+ input: input,
211
+ });
212
+
213
+ console.log("Final output:");
214
+ console.log(response2.output_text);
215
+ ```
216
+
217
+ For more models and parser options, see the [vLLM documentation](https://docs.vllm.ai/en/latest/features/tool_calling/).
@@ -1 +1 @@
1
- {"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../../src/modules/compiler.ts"],"names":[],"mappings":"AAEA,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,iBAclD"}
1
+ {"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../../src/modules/compiler.ts"],"names":[],"mappings":"AAKA,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,iBAkBlD"}
@@ -1,9 +1,13 @@
1
1
  import { build } from 'esbuild';
2
+ import { mkdir } from 'fs/promises';
3
+ import { join } from 'path';
2
4
  export async function ToolCompiler(toolPath) {
3
5
  try {
6
+ const distPath = join(toolPath, 'dist');
7
+ await mkdir(distPath, { recursive: true });
4
8
  await build({
5
9
  entryPoints: [toolPath + '/index.ts'],
6
- outfile: toolPath + '/index.js',
10
+ outfile: join(toolPath, 'dist', 'index.js'),
7
11
  platform: 'node',
8
12
  format: 'esm',
9
13
  target: 'node18',
@@ -1 +1 @@
1
- {"version":3,"file":"compiler.js","sourceRoot":"","sources":["../../src/modules/compiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,QAAgB;IAC/C,IAAI,CAAC;QACD,MAAM,KAAK,CAAC;YACR,WAAW,EAAE,CAAC,QAAQ,GAAG,WAAW,CAAC;YACrC,OAAO,EAAE,QAAQ,GAAG,WAAW;YAC/B,QAAQ,EAAE,MAAM;YAChB,MAAM,EAAE,KAAK;YACb,MAAM,EAAE,QAAQ;YAChB,MAAM,EAAE,KAAK;SAChB,CAAC,CAAC;IACP,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;QAChD,MAAM,KAAK,CAAC;IAChB,CAAC;AACL,CAAC"}
1
+ {"version":3,"file":"compiler.js","sourceRoot":"","sources":["../../src/modules/compiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAG5B,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,QAAgB;IAC/C,IAAI,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACxC,MAAM,KAAK,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAE3C,MAAM,KAAK,CAAC;YACR,WAAW,EAAE,CAAC,QAAQ,GAAG,WAAW,CAAC;YACrC,OAAO,EAAE,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC;YAC3C,QAAQ,EAAE,MAAM;YAChB,MAAM,EAAE,KAAK;YACb,MAAM,EAAE,QAAQ;YAChB,MAAM,EAAE,KAAK;SAChB,CAAC,CAAC;IACP,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;QAChD,MAAM,KAAK,CAAC;IAChB,CAAC;AACL,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aquiles-ai/ishikawa-toolkit",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "Extensible framework for creating and managing LLM function calling",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",