@botbotgo/better-call 0.1.48 → 0.1.49
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/package.json +1 -1
- package/scripts/demo.mjs +16 -10
package/package.json
CHANGED
package/scripts/demo.mjs
CHANGED
|
@@ -3,6 +3,8 @@ import { betterTools, repairToolCall, reliableToolCalls } from "../dist/index.js
|
|
|
3
3
|
|
|
4
4
|
const json = process.argv.includes("--json");
|
|
5
5
|
const VALID_MARKETS = ["US", "HK", "CN"];
|
|
6
|
+
// Intentionally incorrect tool name used to demonstrate tool-call repair behavior.
|
|
7
|
+
const DEMO_INVALID_TOOL_NAME = "stock_price";
|
|
6
8
|
|
|
7
9
|
function errorMessage(error) {
|
|
8
10
|
return error instanceof Error ? error.message : String(error);
|
|
@@ -132,20 +134,24 @@ function repairDemoStockCall(repairInput = {}) {
|
|
|
132
134
|
? repairInput.calls[0].args
|
|
133
135
|
: createDemoMalformedInput();
|
|
134
136
|
|
|
135
|
-
const
|
|
137
|
+
const rawAttemptedTicker =
|
|
136
138
|
typeof attemptedArgs.ticker === "string"
|
|
137
139
|
? attemptedArgs.ticker
|
|
138
140
|
: typeof attemptedArgs.symbol === "string"
|
|
139
141
|
? attemptedArgs.symbol
|
|
140
142
|
: "AAPL";
|
|
143
|
+
const attemptedTicker =
|
|
144
|
+
typeof rawAttemptedTicker === "string" ? rawAttemptedTicker : "AAPL";
|
|
141
145
|
const normalizedTicker = attemptedTicker.trim().toLowerCase();
|
|
142
146
|
// This demo maps empty input and the "apple" alias to AAPL.
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
let ticker;
|
|
148
|
+
if (normalizedTicker === "") {
|
|
149
|
+
ticker = "AAPL";
|
|
150
|
+
} else if (normalizedTicker === "apple") {
|
|
151
|
+
ticker = "AAPL";
|
|
152
|
+
} else {
|
|
153
|
+
ticker = normalizedTicker.toUpperCase();
|
|
154
|
+
}
|
|
149
155
|
|
|
150
156
|
const attemptedMarket = typeof attemptedArgs.market === "string" ? attemptedArgs.market : null;
|
|
151
157
|
const market =
|
|
@@ -197,9 +203,9 @@ try {
|
|
|
197
203
|
userInput: "Get Apple stock in the US market.",
|
|
198
204
|
tools: [stockQuote],
|
|
199
205
|
// Both the tool name and args are intentionally wrong to demonstrate repair:
|
|
200
|
-
//
|
|
206
|
+
// DEMO_INVALID_TOOL_NAME should be "stock_quote"; demoMalformedInput uses
|
|
201
207
|
// "symbol"/"NASDAQ" instead of schema-valid stock_quote args.
|
|
202
|
-
calls: [{ tool:
|
|
208
|
+
calls: [{ tool: DEMO_INVALID_TOOL_NAME, args: demoMalformedInput }],
|
|
203
209
|
repair: repairDemoStockCall,
|
|
204
210
|
});
|
|
205
211
|
} catch (error) {
|
|
@@ -260,7 +266,7 @@ const report = {
|
|
|
260
266
|
after: wrappedOutput,
|
|
261
267
|
},
|
|
262
268
|
reliableToolCalls: {
|
|
263
|
-
before: { tool:
|
|
269
|
+
before: { tool: DEMO_INVALID_TOOL_NAME, args: demoMalformedInput },
|
|
264
270
|
repaired: repairedCall,
|
|
265
271
|
// Optional validation/repair metadata; null means this run returned none.
|
|
266
272
|
diagnostics: reliableResult?.diagnostics ?? null,
|