@botbotgo/better-call 0.1.29 → 0.1.30
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 +12 -3
package/package.json
CHANGED
package/scripts/demo.mjs
CHANGED
|
@@ -39,13 +39,22 @@ const stockQuote = {
|
|
|
39
39
|
|
|
40
40
|
const badArgs = { symbol: "Apple", market: "NASDAQ" };
|
|
41
41
|
|
|
42
|
-
const
|
|
42
|
+
const wrappedTools = betterTools([stockQuote], {
|
|
43
43
|
userInput: "Get Apple stock in the US market.",
|
|
44
44
|
repair() {
|
|
45
45
|
return [{ tool: "stock_quote", args: { ticker: "AAPL", market: "US" } }];
|
|
46
46
|
},
|
|
47
47
|
});
|
|
48
48
|
|
|
49
|
+
if (!Array.isArray(wrappedTools) || wrappedTools.length === 0) {
|
|
50
|
+
exitWithError(
|
|
51
|
+
"tool wrapping",
|
|
52
|
+
new Error("betterTools returned no wrapped tools for stock_quote")
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const wrappedStockQuote = wrappedTools[0];
|
|
57
|
+
|
|
49
58
|
let wrappedOutput;
|
|
50
59
|
try {
|
|
51
60
|
wrappedOutput = await wrappedStockQuote.invoke(badArgs);
|
|
@@ -100,7 +109,7 @@ try {
|
|
|
100
109
|
};
|
|
101
110
|
}
|
|
102
111
|
|
|
103
|
-
const repairedCall = Array.isArray(reliableResult.calls) && reliableResult.calls.length > 0
|
|
112
|
+
const repairedCall = reliableResult && Array.isArray(reliableResult.calls) && reliableResult.calls.length > 0
|
|
104
113
|
? reliableResult.calls[0]
|
|
105
114
|
: null;
|
|
106
115
|
|
|
@@ -112,7 +121,7 @@ const report = {
|
|
|
112
121
|
reliableToolCalls: {
|
|
113
122
|
before: { tool: "stock_price", args: badArgs },
|
|
114
123
|
repaired: repairedCall,
|
|
115
|
-
diagnostics: reliableResult
|
|
124
|
+
diagnostics: reliableResult?.diagnostics ?? null,
|
|
116
125
|
},
|
|
117
126
|
gatewayRepair: gatewayResult,
|
|
118
127
|
};
|