@botbotgo/better-call 0.1.32 → 0.1.33
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 +10 -6
package/package.json
CHANGED
package/scripts/demo.mjs
CHANGED
|
@@ -37,7 +37,9 @@ const stockQuote = {
|
|
|
37
37
|
},
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
// Intentionally malformed repair input: "symbol" should be "ticker", and
|
|
41
|
+
// "NASDAQ" is not one of the schema-valid markets ("US", "HK", or "CN").
|
|
42
|
+
const malformedRepairArgs = { symbol: "Apple", market: "NASDAQ" };
|
|
41
43
|
|
|
42
44
|
const wrappedTools = betterTools([stockQuote], {
|
|
43
45
|
userInput: "Get Apple stock in the US market.",
|
|
@@ -57,7 +59,7 @@ const wrappedStockQuote = wrappedTools[0];
|
|
|
57
59
|
|
|
58
60
|
let wrappedOutput;
|
|
59
61
|
try {
|
|
60
|
-
wrappedOutput = await wrappedStockQuote.invoke(
|
|
62
|
+
wrappedOutput = await wrappedStockQuote.invoke(malformedRepairArgs);
|
|
61
63
|
} catch (error) {
|
|
62
64
|
exitWithError("wrapped stock_quote invocation", error);
|
|
63
65
|
}
|
|
@@ -67,8 +69,10 @@ try {
|
|
|
67
69
|
reliableResult = await reliableToolCalls({
|
|
68
70
|
userInput: "Get Apple stock in the US market.",
|
|
69
71
|
tools: [stockQuote],
|
|
70
|
-
//
|
|
71
|
-
|
|
72
|
+
// Both the tool name and args are intentionally wrong to demonstrate repair:
|
|
73
|
+
// "stock_price" should be "stock_quote"; malformedRepairArgs uses
|
|
74
|
+
// "symbol"/"NASDAQ" instead of schema-valid stock_quote args.
|
|
75
|
+
calls: [{ tool: "stock_price", args: malformedRepairArgs }],
|
|
72
76
|
repair() {
|
|
73
77
|
return [{ tool: "stock_quote", args: { ticker: "AAPL", market: "US" } }];
|
|
74
78
|
},
|
|
@@ -113,11 +117,11 @@ const repairedCall = reliableResult?.calls?.[0] ?? null;
|
|
|
113
117
|
|
|
114
118
|
const report = {
|
|
115
119
|
wrappedTool: {
|
|
116
|
-
before:
|
|
120
|
+
before: malformedRepairArgs,
|
|
117
121
|
after: wrappedOutput,
|
|
118
122
|
},
|
|
119
123
|
reliableToolCalls: {
|
|
120
|
-
before: { tool: "stock_price", args:
|
|
124
|
+
before: { tool: "stock_price", args: malformedRepairArgs },
|
|
121
125
|
repaired: repairedCall,
|
|
122
126
|
diagnostics: reliableResult?.diagnostics ?? null,
|
|
123
127
|
},
|