@botbotgo/better-call 0.1.30 → 0.1.31
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 +6 -8
package/package.json
CHANGED
package/scripts/demo.mjs
CHANGED
|
@@ -37,7 +37,7 @@ const stockQuote = {
|
|
|
37
37
|
},
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
const
|
|
40
|
+
const invalidArgs = { symbol: "Apple", market: "NASDAQ" };
|
|
41
41
|
|
|
42
42
|
const wrappedTools = betterTools([stockQuote], {
|
|
43
43
|
userInput: "Get Apple stock in the US market.",
|
|
@@ -57,7 +57,7 @@ const wrappedStockQuote = wrappedTools[0];
|
|
|
57
57
|
|
|
58
58
|
let wrappedOutput;
|
|
59
59
|
try {
|
|
60
|
-
wrappedOutput = await wrappedStockQuote.invoke(
|
|
60
|
+
wrappedOutput = await wrappedStockQuote.invoke(invalidArgs);
|
|
61
61
|
} catch (error) {
|
|
62
62
|
exitWithError("wrapped stock_quote invocation", error);
|
|
63
63
|
}
|
|
@@ -68,7 +68,7 @@ try {
|
|
|
68
68
|
userInput: "Get Apple stock in the US market.",
|
|
69
69
|
tools: [stockQuote],
|
|
70
70
|
// The tool name is intentionally wrong to demonstrate repair to stock_quote.
|
|
71
|
-
calls: [{ tool: "stock_price", args:
|
|
71
|
+
calls: [{ tool: "stock_price", args: invalidArgs }],
|
|
72
72
|
repair() {
|
|
73
73
|
return [{ tool: "stock_quote", args: { ticker: "AAPL", market: "US" } }];
|
|
74
74
|
},
|
|
@@ -109,17 +109,15 @@ try {
|
|
|
109
109
|
};
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
const repairedCall = reliableResult
|
|
113
|
-
? reliableResult.calls[0]
|
|
114
|
-
: null;
|
|
112
|
+
const repairedCall = reliableResult?.calls?.[0] ?? null;
|
|
115
113
|
|
|
116
114
|
const report = {
|
|
117
115
|
wrappedTool: {
|
|
118
|
-
before:
|
|
116
|
+
before: invalidArgs,
|
|
119
117
|
after: wrappedOutput,
|
|
120
118
|
},
|
|
121
119
|
reliableToolCalls: {
|
|
122
|
-
before: { tool: "stock_price", args:
|
|
120
|
+
before: { tool: "stock_price", args: invalidArgs },
|
|
123
121
|
repaired: repairedCall,
|
|
124
122
|
diagnostics: reliableResult?.diagnostics ?? null,
|
|
125
123
|
},
|