@botbotgo/better-call 0.1.28 → 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 +16 -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,6 +109,10 @@ try {
|
|
|
100
109
|
};
|
|
101
110
|
}
|
|
102
111
|
|
|
112
|
+
const repairedCall = reliableResult && Array.isArray(reliableResult.calls) && reliableResult.calls.length > 0
|
|
113
|
+
? reliableResult.calls[0]
|
|
114
|
+
: null;
|
|
115
|
+
|
|
103
116
|
const report = {
|
|
104
117
|
wrappedTool: {
|
|
105
118
|
before: badArgs,
|
|
@@ -107,8 +120,8 @@ const report = {
|
|
|
107
120
|
},
|
|
108
121
|
reliableToolCalls: {
|
|
109
122
|
before: { tool: "stock_price", args: badArgs },
|
|
110
|
-
repaired:
|
|
111
|
-
diagnostics: reliableResult
|
|
123
|
+
repaired: repairedCall,
|
|
124
|
+
diagnostics: reliableResult?.diagnostics ?? null,
|
|
112
125
|
},
|
|
113
126
|
gatewayRepair: gatewayResult,
|
|
114
127
|
};
|